結果

問題 No.2535 多重同値
ユーザー titiatitia
提出日時 2023-11-11 00:25:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 461 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 49,048 KB
最終ジャッジ日時 2023-11-11 00:25:58
合計ジャッジ時間 3,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 30 ms
10,112 KB
testcase_03 AC 30 ms
10,112 KB
testcase_04 AC 30 ms
10,112 KB
testcase_05 AC 30 ms
10,112 KB
testcase_06 AC 30 ms
10,112 KB
testcase_07 AC 31 ms
10,112 KB
testcase_08 AC 30 ms
10,112 KB
testcase_09 AC 31 ms
10,112 KB
testcase_10 AC 30 ms
10,112 KB
testcase_11 AC 30 ms
10,112 KB
testcase_12 AC 30 ms
10,112 KB
testcase_13 AC 32 ms
10,112 KB
testcase_14 AC 31 ms
10,112 KB
testcase_15 AC 36 ms
10,368 KB
testcase_16 AC 69 ms
13,308 KB
testcase_17 AC 449 ms
49,048 KB
testcase_18 AC 461 ms
49,048 KB
testcase_19 AC 446 ms
49,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
from functools import lru_cache
@lru_cache(maxsize=None)
def calc(i,x):
    #print(i,x)
    if i==0:
        return S[x]
    elif i==1:
        return x

    else:
        if S[i-2]==x:
            return calc(i-1,"Yes")
        else:
            return calc(i-1,"No")


N=int(input())
S=[input().strip() for i in range(N)]

print(S[0])
for i in range(1,N):
    if S[i]==S[i-1]:
        print(calc(i,"Yes"))
    else:
        print(calc(i,"No"))
0