結果

問題 No.2343 (l+r)/2
ユーザー lingfunnylingfunny
提出日時 2023-06-09 23:06:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 3,697 ms
コンパイル使用メモリ 275,660 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 05:07:39
合計ジャッジ時間 4,472 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         for (scanf("%d", &TestCase); TestCase--;) {
      |              ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d", &n);
      |                 ~~~~~^~~~~~~~~~
main.cpp:15:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 for (int &x : a) scanf("%d", &x);
      |                                  ~~~~~^~~~~~~~~~

ソースコード

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