結果

問題 No.2518 Adjacent Larger
ユーザー sasa8uyauya
提出日時 2023-10-27 21:45:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 108,124 KB
最終ジャッジ日時 2024-09-25 13:50:46
合計ジャッジ時間 3,020 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18 WA * 10
権限があれば一括ダウンロードができます

ソースコード

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