結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 340 ms
81,808 KB
testcase_01 AC 80 ms
76,692 KB
testcase_02 AC 85 ms
98,976 KB
testcase_03 AC 36 ms
54,324 KB
testcase_04 WA -
testcase_05 AC 92 ms
77,484 KB
testcase_06 AC 255 ms
198,920 KB
testcase_07 AC 543 ms
318,436 KB
testcase_08 AC 537 ms
318,336 KB
testcase_09 AC 174 ms
82,640 KB
testcase_10 AC 189 ms
83,572 KB
testcase_11 AC 153 ms
82,336 KB
testcase_12 AC 295 ms
77,064 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 265 ms
120,384 KB
testcase_16 AC 281 ms
182,572 KB
権限があれば一括ダウンロードができます

ソースコード

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]
    ind = 0
    d = minv
    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
        else:
            xlst = X[len(X)//d * d:] * ((len(X) + len(Y) + 1)//len(Y))
            if ylst < xlst:
                ind = 0
            elif ylst > xlst:
                ind = 1
    print(ans[ind^flag])
0