結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー Akijin_007Akijin_007
提出日時 2022-10-14 22:50:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,668 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 284,628 KB
最終ジャッジ日時 2023-09-08 23:12:05
合計ジャッジ時間 45,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,132 KB
testcase_01 AC 66 ms
71,504 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 376 ms
172,168 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 310 ms
140,216 KB
testcase_18 AC 501 ms
193,036 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 861 ms
119,428 KB
testcase_43 AC 853 ms
119,392 KB
testcase_44 AC 866 ms
118,764 KB
testcase_45 AC 870 ms
118,972 KB
testcase_46 AC 857 ms
119,444 KB
testcase_47 AC 415 ms
188,464 KB
testcase_48 AC 454 ms
189,712 KB
testcase_49 AC 426 ms
189,016 KB
testcase_50 AC 436 ms
189,416 KB
testcase_51 AC 448 ms
188,780 KB
testcase_52 AC 264 ms
168,908 KB
testcase_53 AC 260 ms
170,500 KB
testcase_54 AC 263 ms
169,720 KB
testcase_55 AC 274 ms
148,932 KB
testcase_56 AC 275 ms
148,688 KB
testcase_57 AC 278 ms
148,408 KB
testcase_58 AC 256 ms
139,884 KB
testcase_59 WA -
testcase_60 AC 249 ms
91,768 KB
testcase_61 AC 280 ms
148,288 KB
testcase_62 WA -
testcase_63 AC 271 ms
85,132 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 380 ms
96,356 KB
testcase_68 WA -
testcase_69 AC 393 ms
104,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N = int(input())

S = [0] * N
for i in range(N):
    S[i] = input()

d = dict()
ans = [0] * N

def check(x, y):
    if len(x) != len(y):
        return 0
    dif = []
    for i in range(len(x)):
        if x[i] != y[i]:
            dif.append(i)
    if len(dif) == 0:
        return 1
    elif len(dif) == 2:
        u = dif[0]
        v = dif[1]
        if u + 1 == v and x[u] == y[v] and x[v] and y[u]:
            return 1
        else:
            return 0
    else:
        return 0

for i in range(N):
    a = []
    u, v = divmod(len(S[i]), 2)
    u += v
    for j in range(u):
        s = S[i][2*j:2*j+2]
        if len(s) == 1:
            a.append(s)
            continue
        if s[0] < s[1]:
            a.append(s)
        else:
            a.append(s[1] + s[0])
    t = tuple(a)
    if t not in d:
        d[t] = [i]
    else:
        for x in d[t]:
            if check(S[i], S[x]):
                ans[i] = 1
                break
        d[t].append(i)

d = dict()

for i in range(N):
    if ans[i] == 1:
        continue
    a = [S[i][0]]
    u, v = divmod(len(S[i]), 2)
    for j in range(u):
        s = S[i][2*j+1:2*j+3]
        if len(s) == 1:
            a.append(s)
            continue
        if s[0] < s[1]:
            a.append(s)
        else:
            a.append(s[1] + s[0])
    t = tuple(a)
    if t not in d:
        d[t] = [i]
    else:
        for x in d[t]:
            if check(S[i], S[x]):
                ans[i] = 1
                break
        d[t].append(i)

for i in range(N):
    if ans[i] == 1:
        print("Yes")
    else:
        print("No")
0