跳到正文

题解

题解:AT_arc192_a [ARC192A] ARC Arc

Gardenia_Scent约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

思路

首先考虑一种连续的染色 CRARCRACRARCRA,根据 n mod 4n \bmod 4 的值分类讨论。

当余数为 00 时:可以全部覆盖完。

当余数为 11 时:怎么样会都剩一个不行,而且如果断开也会有一个不能覆盖。

当余数为 33 时:怎么样会都剩 4−3=14−3=1 个不行,而且如果断开也会有一个不能覆盖。

当余数为 22 时,会剩 22 个空位,只需要考虑它们的相对位置。

填完后,应当使得这两个空位的长度模 44 为 22,剩下的就可以全部覆盖。

code

C++
cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> a(n), b(2);
	for (int i = 0; i < n; i ++) cin >> a[i];
	if (n % 4 == 0) cout << "Yes\n";
	else if (n % 4 == 2) {
		for (int i = 0; i < n; i ++) {
			if (a[i] && b[(i & 1) ^ 1]) return cout << "Yes\n", 0;
			else if (a[i]) b[i & 1] = 1;
		}
		cout << "No\n";
	}else if (n % 4 == 3 || n % 4 == 1) {
		if (count(a.begin(), a.end(), 1) == 0) cout << "No\n";
		else cout << "Yes\n";
	}
	return 0;
}
原文