結果

問題 No.3587 Too Good to Swap
コンテスト
ユーザー marc2825
提出日時 2026-07-10 18:51:09
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 517 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 272 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 86,160 KB
最終ジャッジ日時 2026-07-10 21:08:52
合計ジャッジ時間 6,187 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def is_wall(X):
    rgidx = -1
    ldidx = -1

    for i in range(len(X)):
        if X[i] == "g":
            rgidx = i
        elif X[i] == "d" and ldidx == -1:
            ldidx = i

    return rgidx != -1 and ldidx != -1 and ldidx - rgidx > 3


Q = int(input())

for _ in range(Q):
    S = input()
    T = input()

    cnts = {c: S.count(c) for c in "dog"}
    cntt = {c: T.count(c) for c in "dog"}

    if cnts != cntt:
        print("No")
        continue

    print("Yes" if is_wall(S) == is_wall(T) else "No")
0