結果

問題 No.2030 Googol Strings
ユーザー mkawa2mkawa2
提出日時 2022-08-05 22:17:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,363 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 81,116 KB
最終ジャッジ日時 2023-10-13 23:27:00
合計ジャッジ時間 3,552 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
77,512 KB
testcase_01 AC 78 ms
71,472 KB
testcase_02 AC 77 ms
71,328 KB
testcase_03 AC 73 ms
71,160 KB
testcase_04 AC 135 ms
77,932 KB
testcase_05 AC 95 ms
75,908 KB
testcase_06 AC 111 ms
80,528 KB
testcase_07 AC 134 ms
81,116 KB
testcase_08 AC 132 ms
80,788 KB
testcase_09 AC 85 ms
75,512 KB
testcase_10 AC 85 ms
75,392 KB
testcase_11 AC 85 ms
75,596 KB
testcase_12 AC 142 ms
78,632 KB
testcase_13 AC 176 ms
77,652 KB
testcase_14 AC 108 ms
75,952 KB
testcase_15 AC 153 ms
76,668 KB
testcase_16 AC 131 ms
77,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

from math import gcd

def same(x,y):
    g=gcd(len(x),len(y))
    s=x[:g]
    for i in range(0,len(x),g):
        if x[i:i+g]!=s:return False
    for i in range(0,len(y),g):
        if y[i:i+g]!=s:return False
    return True

def solve():
    x=SI()
    y=SI()
    m,n=len(x),len(y)
    if same(x,y):
        if len(x)>len(y):
            print("X")
        else:
            print("Y")
    else:
        i=0
        while 1:
            if x[i%m]>y[i%n]:
                print("X")
                break
            if x[i%m]<y[i%n]:
                print("Y")
                break
            i+=1

for _ in range(II()):
    solve()
0