結果

問題 No.2030 Googol Strings
ユーザー gr1msl3ygr1msl3y
提出日時 2022-08-16 23:57:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 77,876 KB
最終ジャッジ日時 2024-04-14 17:39:41
合計ジャッジ時間 3,281 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
77,876 KB
testcase_01 AC 41 ms
60,220 KB
testcase_02 AC 38 ms
57,960 KB
testcase_03 AC 36 ms
54,040 KB
testcase_04 AC 115 ms
77,336 KB
testcase_05 AC 52 ms
65,044 KB
testcase_06 AC 64 ms
68,320 KB
testcase_07 AC 83 ms
70,524 KB
testcase_08 AC 82 ms
71,112 KB
testcase_09 AC 43 ms
61,348 KB
testcase_10 AC 43 ms
61,388 KB
testcase_11 AC 44 ms
60,920 KB
testcase_12 AC 112 ms
77,816 KB
testcase_13 AC 136 ms
76,676 KB
testcase_14 AC 62 ms
67,604 KB
testcase_15 AC 88 ms
72,516 KB
testcase_16 AC 77 ms
72,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd


def solve(x, y):
    a = len(x)
    b = len(y)
    g = gcd(a, b)
    s = x[:g]
    if x == s*(a//g) and y == s*(b//g):
        return 'X' if a > b else 'Y'
    i = 0
    while True:
        p = ord(x[i % a])
        q = ord(y[i % b])
        if p > q:
            return 'X'
        elif p < q:
            return 'Y'
        else:
            i += 1


def main():
    T = int(input())
    ans = []
    for _ in range(T):
        x = input()
        y = input()
        ans.append(solve(x, y))
    print(*ans, sep='\n')


main()
0