結果

問題 No.2030 Googol Strings
ユーザー rlangevinrlangevin
提出日時 2022-08-21 17:46:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 318,376 KB
最終ジャッジ日時 2024-04-18 13:05:47
合計ジャッジ時間 6,357 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 80 ms
76,868 KB
testcase_02 AC 85 ms
97,904 KB
testcase_03 AC 35 ms
52,444 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 226 ms
194,744 KB
testcase_07 AC 499 ms
318,376 KB
testcase_08 AC 485 ms
318,364 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def div(n):
    S = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            S.add(i)
            S.add(n // i)
        i += 1
    return list(S)

T = int(input())
ans = ["X", "Y"]
for _ in range(T):
    X = list(input())
    Y = list(input())
    flag = 0
    if len(X) <= len(Y):
        flag = 1
        X, Y = Y, X
    minv = 10 ** 18
    for d in div(len(Y)):
        S = set()    
        for i in range(len(Y)//d):
            S.add(tuple(Y[i * d:(i + 1)*d]))
            if len(S) == 2:
                break
        if len(S) == 1 and d < minv:
            minv = d
            ylst = Y[:d]
    i = 0
    ind = 0
    for i in range(len(X)//d):
        xlst = X[i * d:(i + 1)*d]
        if ylst < xlst:
            ind = 0
            break
        elif ylst > xlst:
            ind = 1
            break
    else:
        if len(X) % d == 0:
            ind = 0
    print(ans[ind^flag])
0