結果

問題 No.3798 algo to goal
ユーザー gn1t0
提出日時 2026-11-09 00:50:09
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,012 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 113 ms
コンパイル使用メモリ 64,128 KB
実行使用メモリ 71,984 KB
最終ジャッジ日時 2026-11-13 22:06:08
合計ジャッジ時間 18,871 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5 WA * 15 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict, Counter

Q = int(input())

for case in range(Q):
    S = input()
    T = input()
    N = len(S)

    S1 = S[::2]
    S2 = S[1::2]
    T1 = T[::2]
    T2 = T[1::2]
    countS1 = Counter(S1)
    countS2 = Counter(S2)
    countT1 = Counter(T1)
    countT2 = Counter(T2)


    if (countS1 != countT1) or (countS2 != countT2):
        print("No")
        continue



    invS1 = 0
    invS2 = 0
    invT1 = 0
    invT2 = 0
    for i in range(len(S1)):
        for j in range(i + 1, len(S1)):
            if ord(S1[i]) > ord(S1[j]):
                invS1 += 1
            if ord(T1[i]) > ord(T1[j]):
                invT1 += 1

    for i in range(len(S2)):
        for j in range(i + 1, len(S2)):
            if ord(S2[i]) > ord(S2[j]):
                invS2 += 1
            if ord(T2[i]) > ord(T2[j]):
                invT2 += 1

    diff1 = abs(invS1 - invT1)
    diff2 = abs(invS2 - invT2)

    if (diff1 % 2) == (diff2 % 2):
        print("Yes")
    else:
        print("No")
0