結果

問題 No.2518 Adjacent Larger
ユーザー sasa8uyauyasasa8uyauya
提出日時 2023-10-27 21:46:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 108,004 KB
最終ジャッジ日時 2023-10-27 21:46:58
合計ジャッジ時間 4,518 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,532 KB
testcase_01 AC 245 ms
78,784 KB
testcase_02 AC 230 ms
79,360 KB
testcase_03 AC 220 ms
78,268 KB
testcase_04 AC 216 ms
78,192 KB
testcase_05 AC 238 ms
78,420 KB
testcase_06 AC 126 ms
77,144 KB
testcase_07 AC 112 ms
76,948 KB
testcase_08 AC 115 ms
77,016 KB
testcase_09 AC 127 ms
76,960 KB
testcase_10 AC 124 ms
76,964 KB
testcase_11 AC 67 ms
75,520 KB
testcase_12 AC 67 ms
75,500 KB
testcase_13 AC 74 ms
75,580 KB
testcase_14 AC 62 ms
74,148 KB
testcase_15 AC 91 ms
75,496 KB
testcase_16 AC 86 ms
105,112 KB
testcase_17 AC 70 ms
86,464 KB
testcase_18 AC 70 ms
86,572 KB
testcase_19 AC 67 ms
83,924 KB
testcase_20 AC 75 ms
93,912 KB
testcase_21 AC 94 ms
107,520 KB
testcase_22 AC 94 ms
108,004 KB
testcase_23 AC 90 ms
105,260 KB
testcase_24 AC 83 ms
102,852 KB
testcase_25 AC 86 ms
103,964 KB
testcase_26 AC 87 ms
103,976 KB
testcase_27 AC 86 ms
106,808 KB
testcase_28 AC 82 ms
103,044 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")
    continue
  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