結果

問題 No.2518 Adjacent Larger
ユーザー k82bk82b
提出日時 2023-10-28 01:10:51
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,263 bytes
コンパイル時間 1,742 ms
コンパイル使用メモリ 168,460 KB
実行使用メモリ 12,360 KB
最終ジャッジ日時 2023-10-28 01:10:55
合計ジャッジ時間 2,757 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 6 ms
4,348 KB
testcase_07 AC 6 ms
4,348 KB
testcase_08 AC 7 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 6 ms
5,312 KB
testcase_12 AC 5 ms
5,312 KB
testcase_13 AC 5 ms
5,312 KB
testcase_14 AC 5 ms
5,312 KB
testcase_15 AC 5 ms
5,312 KB
testcase_16 AC 20 ms
12,360 KB
testcase_17 AC 9 ms
5,088 KB
testcase_18 AC 10 ms
5,088 KB
testcase_19 AC 8 ms
5,088 KB
testcase_20 AC 12 ms
5,876 KB
testcase_21 AC 16 ms
12,360 KB
testcase_22 AC 15 ms
12,360 KB
testcase_23 AC 18 ms
12,360 KB
testcase_24 AC 16 ms
12,360 KB
testcase_25 AC 18 ms
12,360 KB
testcase_26 AC 17 ms
12,360 KB
testcase_27 AC 16 ms
12,360 KB
testcase_28 AC 18 ms
12,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main()
{
	const TE = readInt;
	foreach (_; 0 .. TE) {
		const N = readInt;
		auto A = new int[N];
		foreach (i; 0 .. N) {
			A[i] = readInt;
		}
		bool ans = true;
		foreach (i; 0 .. N) {
			ans = ans && !(A[i] == 2 && A[(i + 1) % N] == 2);
			ans = ans && !(A[i] == 0 && A[(i + 1) % N] == 0);
			ans = ans && !(A[(i - 1 + N) % N] == 0 && A[i] == 1 && A[(i + 1) % N] == 0);
			ans = ans && !(A[(i - 1 + N) % N] == 2 && A[i] == 1 && A[(i + 1) % N] == 2);
		}
		ans = ans && cast(int)(A.count(1)) < N;
		ans = ans && A.sum == N;
		writeln(ans ? "Yes" : "No");
	}
}

import std,core.bitop;
string[]_R;
string readString(){while(_R.empty){_R=readln.chomp.split;}auto ret=_R.front;_R.popFront;return ret;}
int readInt(){return readString.to!int;}
long readLong(){return readString.to!long;}
ulong readULong(){return readString.to!ulong;}
real readReal(){return readString.to!real;}
bool chmin(T)(ref T A,T B){if(A>B){A=B;return true;}else{return false;}}
bool chmax(T)(ref T A,T B){if(A<B){A=B;return true;}else{return false;}}
int lowerBound(T)(T[]A,T x){int L=-1,R=cast(int)A.length;while(R-L>1){int mid=(L+R)/2;(A[mid]<x?L:R)=mid;}return R;}
int upperBound(T)(T[]A,T x){int L=-1,R=cast(int)A.length;while(R-L>1){int mid=(L+R)/2;(A[mid]<=x?L:R)=mid;}return R;}
0