結果

問題 No.2518 Adjacent Larger
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-10-27 22:20:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 3,092 ms
コンパイル使用メモリ 204,124 KB
実行使用メモリ 4,844 KB
最終ジャッジ日時 2023-10-27 22:20:59
合計ジャッジ時間 3,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 35 ms
4,348 KB
testcase_02 AC 35 ms
4,348 KB
testcase_03 AC 34 ms
4,348 KB
testcase_04 AC 34 ms
4,348 KB
testcase_05 AC 35 ms
4,348 KB
testcase_06 AC 11 ms
4,348 KB
testcase_07 AC 12 ms
4,348 KB
testcase_08 AC 12 ms
4,348 KB
testcase_09 AC 11 ms
4,348 KB
testcase_10 AC 12 ms
4,348 KB
testcase_11 AC 10 ms
4,348 KB
testcase_12 AC 11 ms
4,348 KB
testcase_13 AC 10 ms
4,348 KB
testcase_14 AC 10 ms
4,348 KB
testcase_15 AC 10 ms
4,348 KB
testcase_16 AC 34 ms
4,844 KB
testcase_17 AC 20 ms
4,348 KB
testcase_18 AC 20 ms
4,348 KB
testcase_19 AC 17 ms
4,348 KB
testcase_20 AC 25 ms
4,476 KB
testcase_21 AC 34 ms
4,844 KB
testcase_22 AC 34 ms
4,844 KB
testcase_23 AC 35 ms
4,844 KB
testcase_24 AC 32 ms
4,844 KB
testcase_25 AC 34 ms
4,844 KB
testcase_26 AC 33 ms
4,844 KB
testcase_27 AC 34 ms
4,844 KB
testcase_28 AC 35 ms
4,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
void solve() {
	int N;
	cin >> N;
	std::vector<int> A(N);
	for (auto& a : A) {
		cin >> a;
	}
	bool zr = false, tw = false;
	for (int i = 0; i < N; i ++) {
		zr = zr || (A[i] == 0);
		tw = tw || (A[i] == 2);
	}
	if (!(zr && tw)) {
		puts("No");
		return;
	}
	for (int i = 0; i < N; i ++) {
		A.push_back(A[i]);
	}
	int pre = 0;
	for (auto a : A) {
		if ((a - 1) * pre > 0) {
			puts("No");
			return ;
		}
		if (a - 1) {
			pre = a - 1;
		}
	}
	puts("Yes");
}
int main() {
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
}
0