結果

問題 No.2343 (l+r)/2
ユーザー lingfunnylingfunny
提出日時 2023-06-09 23:06:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 3,369 ms
コンパイル使用メモリ 243,912 KB
実行使用メモリ 5,240 KB
最終ジャッジ日時 2023-08-30 14:17:21
合計ジャッジ時間 3,966 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 42 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 10 ms
4,528 KB
testcase_05 WA -
testcase_06 AC 4 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 12 ms
4,628 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 14 ms
5,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
using uint = unsigned;
using namespace std;

const int mxn = 2e5 + 10;

int TestCase, f[mxn][3];

signed main() {
	for (scanf("%d", &TestCase); TestCase--;) {
		int n;
		scanf("%d", &n);
		vector<int> a(n);
		for (int &x : a) scanf("%d", &x);
		for (int i = 0; i <= n; ++i) memset(f[i], 0, sizeof f[i]);
		f[0][1] = f[1][a[0] * 2] = 1;
		for (int i = 2; i <= n; ++i) {
			if (a[i - 1] == a[i - 2])
				for (int k = 0; k < 3; ++k) f[i][k] |= f[i - 1][k];
			else f[i][1] |= f[i - 2][1];
			if (a[i - 1] == 0) {
				f[i][0] |= f[i - 1][0];
				f[i][1] |= f[i - 1][2];
			} else {
				f[i][1] |= f[i - 1][0];
				f[i][2] |= f[i - 1][2];
			}
		}
		puts(f[n][1] ? "Yes" : "No");
	}
	return 0;
}
0