結果

問題 No.2518 Adjacent Larger
ユーザー sasa8uyauyasasa8uyauya
提出日時 2023-10-27 21:45:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 107,952 KB
最終ジャッジ日時 2023-10-27 21:45:17
合計ジャッジ時間 2,907 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,472 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 64 ms
75,472 KB
testcase_12 AC 64 ms
75,440 KB
testcase_13 AC 67 ms
75,524 KB
testcase_14 AC 59 ms
74,100 KB
testcase_15 AC 61 ms
75,428 KB
testcase_16 AC 81 ms
105,056 KB
testcase_17 AC 67 ms
86,408 KB
testcase_18 AC 65 ms
86,516 KB
testcase_19 AC 64 ms
83,868 KB
testcase_20 AC 73 ms
93,856 KB
testcase_21 AC 88 ms
107,464 KB
testcase_22 AC 92 ms
107,952 KB
testcase_23 AC 92 ms
105,204 KB
testcase_24 AC 77 ms
102,796 KB
testcase_25 AC 77 ms
103,908 KB
testcase_26 AC 79 ms
103,920 KB
testcase_27 AC 82 ms
106,752 KB
testcase_28 AC 76 ms
102,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
for _ in range(t):
  n=int(input())
  a=list(map(int,input().split()))
  if (0 not in a) or (2 not in a):
    print("No")
    exit()
  i=0
  while a[i]!=0:
    i+=1
  a=a[i:]+a[:i]
  c=[""]*(n+1)
  c[0]=">"
  c[-1]="<"
  f=1
  for i in range(1,n):
    if a[i]==0:
      c[i]=">"
      if c[i-1]!="<" and f:
        print("No")
        f=0
    if a[i]==1:
      if c[i-1]=="<":
        c[i]="<"
      if c[i-1]==">":
        c[i]=">"
    if a[i]==2:
      c[i]="<"
      if c[i-1]!=">" and f:
        print("No")
        f=0
  if f:
    print(["No","Yes"][c[-1]==c[n-1]])
0