結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,368 KB
testcase_01 AC 66 ms
71,296 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 378 ms
172,572 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 307 ms
140,372 KB
testcase_18 AC 494 ms
193,224 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 807 ms
119,468 KB
testcase_43 AC 806 ms
119,368 KB
testcase_44 AC 864 ms
118,780 KB
testcase_45 AC 807 ms
118,964 KB
testcase_46 AC 840 ms
119,656 KB
testcase_47 AC 415 ms
188,672 KB
testcase_48 AC 462 ms
189,504 KB
testcase_49 AC 442 ms
188,792 KB
testcase_50 AC 437 ms
189,644 KB
testcase_51 AC 408 ms
188,744 KB
testcase_52 AC 263 ms
169,284 KB
testcase_53 AC 263 ms
170,428 KB
testcase_54 AC 263 ms
169,648 KB
testcase_55 AC 275 ms
148,588 KB
testcase_56 AC 276 ms
148,680 KB
testcase_57 AC 280 ms
148,780 KB
testcase_58 AC 232 ms
140,124 KB
testcase_59 WA -
testcase_60 AC 253 ms
92,096 KB
testcase_61 AC 277 ms
148,740 KB
testcase_62 WA -
testcase_63 AC 268 ms
85,096 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 386 ms
96,476 KB
testcase_68 WA -
testcase_69 AC 378 ms
104,528 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] == 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)

# print(d)

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