結果

問題 No.2535 多重同値
ユーザー yupoohyupooh
提出日時 2023-11-10 22:17:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 81,912 KB
最終ジャッジ日時 2023-11-10 22:18:00
合計ジャッジ時間 2,239 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 36 ms
53,460 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 35 ms
53,460 KB
testcase_11 AC 36 ms
53,460 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 35 ms
53,460 KB
testcase_14 AC 36 ms
53,460 KB
testcase_15 AC 44 ms
61,140 KB
testcase_16 AC 84 ms
76,556 KB
testcase_17 AC 107 ms
81,016 KB
testcase_18 AC 101 ms
81,912 KB
testcase_19 AC 100 ms
81,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
n=int(input())
P=[]
for i in range(n):
  p=input().rstrip()
  if n==1:
    print(p)
    exit()
  if p=="Yes":
    P.append(1)
  else:
    P.append(0)
memo=[0]*n
for i in range(n-2,-1,-1):
  if P[i]==P[i+1]:
    flg=1
  else:
    flg=0
  if flg==P[i]:
    memo[i]=memo[i+1]
  else:
    memo[i]=1-memo[i+1]
if P[-2]==P[-1]:
  now=1
else:
  now=0
for i in range(n-3,-1,-1):
  if now==P[i]:
    now=1
  else:
    now=0
ans=[0]*n
ans[-1]=now
for i in range(n-2,-1,-1):
  if memo[i]==0:
    ans[i]=ans[-1]
  else:
    ans[i]=1-ans[-1]
for i in ans:
  if i==0:
    print("No")
  else:
    print("Yes")
0