結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー Akijin_007Akijin_007
提出日時 2022-10-14 22:58:53
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,003 ms / 3,000 ms
コード長 1,682 bytes
コンパイル時間 1,795 ms
コンパイル使用メモリ 86,412 KB
実行使用メモリ 284,904 KB
最終ジャッジ日時 2023-09-08 23:22:38
合計ジャッジ時間 50,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,132 KB
testcase_01 AC 67 ms
70,776 KB
testcase_02 AC 655 ms
167,608 KB
testcase_03 AC 705 ms
198,136 KB
testcase_04 AC 694 ms
168,120 KB
testcase_05 AC 628 ms
133,816 KB
testcase_06 AC 775 ms
177,732 KB
testcase_07 AC 399 ms
172,256 KB
testcase_08 AC 380 ms
98,404 KB
testcase_09 AC 599 ms
190,152 KB
testcase_10 AC 495 ms
115,152 KB
testcase_11 AC 375 ms
121,684 KB
testcase_12 AC 578 ms
157,656 KB
testcase_13 AC 684 ms
215,868 KB
testcase_14 AC 690 ms
152,100 KB
testcase_15 AC 836 ms
183,968 KB
testcase_16 AC 905 ms
237,160 KB
testcase_17 AC 323 ms
140,208 KB
testcase_18 AC 516 ms
192,716 KB
testcase_19 AC 522 ms
132,524 KB
testcase_20 AC 710 ms
228,972 KB
testcase_21 AC 538 ms
116,468 KB
testcase_22 AC 911 ms
253,824 KB
testcase_23 AC 912 ms
254,956 KB
testcase_24 AC 943 ms
256,584 KB
testcase_25 AC 908 ms
255,624 KB
testcase_26 AC 916 ms
254,308 KB
testcase_27 AC 903 ms
255,748 KB
testcase_28 AC 912 ms
253,264 KB
testcase_29 AC 915 ms
253,492 KB
testcase_30 AC 887 ms
255,412 KB
testcase_31 AC 948 ms
255,600 KB
testcase_32 AC 954 ms
257,472 KB
testcase_33 AC 950 ms
257,348 KB
testcase_34 AC 906 ms
256,296 KB
testcase_35 AC 924 ms
254,620 KB
testcase_36 AC 940 ms
255,188 KB
testcase_37 AC 947 ms
255,316 KB
testcase_38 AC 904 ms
255,312 KB
testcase_39 AC 958 ms
255,296 KB
testcase_40 AC 915 ms
257,016 KB
testcase_41 AC 931 ms
255,408 KB
testcase_42 AC 936 ms
119,144 KB
testcase_43 AC 941 ms
118,796 KB
testcase_44 AC 940 ms
118,460 KB
testcase_45 AC 929 ms
118,764 KB
testcase_46 AC 905 ms
119,096 KB
testcase_47 AC 439 ms
188,408 KB
testcase_48 AC 473 ms
189,344 KB
testcase_49 AC 463 ms
188,880 KB
testcase_50 AC 461 ms
189,100 KB
testcase_51 AC 443 ms
188,188 KB
testcase_52 AC 266 ms
168,688 KB
testcase_53 AC 267 ms
170,024 KB
testcase_54 AC 266 ms
169,260 KB
testcase_55 AC 283 ms
148,492 KB
testcase_56 AC 283 ms
148,308 KB
testcase_57 AC 287 ms
148,268 KB
testcase_58 AC 300 ms
174,612 KB
testcase_59 AC 1,003 ms
284,904 KB
testcase_60 AC 496 ms
95,500 KB
testcase_61 AC 294 ms
148,288 KB
testcase_62 AC 204 ms
80,120 KB
testcase_63 AC 369 ms
86,060 KB
testcase_64 AC 447 ms
87,296 KB
testcase_65 AC 558 ms
88,176 KB
testcase_66 AC 762 ms
120,820 KB
testcase_67 AC 501 ms
98,136 KB
testcase_68 AC 297 ms
99,168 KB
testcase_69 AC 509 ms
112,232 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):
    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:
        if ans[i] != 1:
            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