結果
| 問題 | No.3798 algo to goal |
| ユーザー |
|
| 提出日時 | 2026-11-13 22:52:34 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 631 ms / 2,000 ms |
| + 485µs | |
| コード長 | 1,989 bytes |
| 記録 | |
| コンパイル時間 | 81 ms |
| コンパイル使用メモリ | 64,384 KB |
| 実行使用メモリ | 143,168 KB |
| 最終ジャッジ日時 | 2026-11-13 22:53:09 |
| 合計ジャッジ時間 | 17,915 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 40 |
ソースコード
import sys
sys.setrecursionlimit(10**7)
#↓codon===============================
import string
Alp_low=list(string.ascii_lowercase)
Alp_up=list(string.ascii_uppercase)
Digit="0123456789"
dij=[[0,1],[1,0],[0,-1],[-1,0]]
def nin():
"""
library
https://github.com/not522/ac-library-python
https://github.com/cheran-senthil/PyRival
https://github.com/kurao2924/Kurao_Py_Library
https://github.com/navel-tos/cp-library-for-codon
"""
return list(map(int,input().split()))
def deq(x):
return [i-1 for i in x]
mod=998244353
_factorial=[1]
def factorial(n):
while len(_factorial)<=n:
_factorial.append((_factorial[-1]*len(_factorial))%mod)
return _factorial[n]
_inv_factorial=[1]
def inv_factorial(n):
while len(_inv_factorial)<=n:
_inv_factorial.append((_inv_factorial[-1]*pow(len(_inv_factorial),mod-2,mod))%mod)
return _inv_factorial[n]
def binom(n,r):
if r>=mod:
raise ValueError("r is too big")
if n<0:
return 0
if r>n:
return 0
if r<0:
return 0
ans=((factorial(n)*inv_factorial(r))%mod*inv_factorial(n-r))%mod
return ans
mod=998244353
def main():
def ten(s,t):
d={}
for i in range(len(s)):
d[s[i]]=i
x=[d[t[i]] for i in range(len(t))]
ans=0
for i in range(len(x)):
for j in range(i+1,len(x)):
if x[i]>x[j]:
ans^=1
return ans
q,=nin()
for _ in range(q):
s=input()
t=input()
n=len(s)
x1=s[::2]
x2=s[1::2]
y1=t[::2]
y2=t[1::2]
if not (sorted(list(x1))==sorted(list(y1)) and sorted(list(x2))==sorted(list(y2))):
print("No")
continue
if len(set(x1))!=len(x1) or len(set(x2))!=len(x2):
print("Yes")
continue
if ten(x1,y1)==ten(x2,y2):
print("Yes")
else:
print("No")
if __name__=="__main__":
main()