結果

問題 No.1779 Magical Swap
ユーザー gr1msl3ygr1msl3y
提出日時 2021-12-25 01:39:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 97,092 KB
最終ジャッジ日時 2023-10-20 05:21:20
合計ジャッジ時間 4,968 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
63,136 KB
testcase_01 AC 46 ms
63,136 KB
testcase_02 AC 132 ms
77,876 KB
testcase_03 AC 51 ms
65,456 KB
testcase_04 AC 116 ms
91,900 KB
testcase_05 AC 76 ms
83,868 KB
testcase_06 AC 85 ms
87,588 KB
testcase_07 AC 107 ms
92,604 KB
testcase_08 AC 50 ms
65,444 KB
testcase_09 AC 65 ms
77,476 KB
testcase_10 AC 123 ms
92,076 KB
testcase_11 AC 90 ms
89,436 KB
testcase_12 AC 61 ms
74,248 KB
testcase_13 AC 109 ms
91,812 KB
testcase_14 AC 129 ms
97,092 KB
testcase_15 AC 261 ms
85,240 KB
testcase_16 AC 120 ms
95,576 KB
testcase_17 AC 129 ms
77,336 KB
testcase_18 AC 47 ms
63,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M=10**5
primeset=set()
isprime=[1]*(M+1)
isprime[0]=isprime[1]=0
for i in range(2,M+1):
    if not isprime[i]: continue
    primeset.add(i)
    for j in range(i*i,M+1,i):
        isprime[j]=0


def solve(N,A,B):
    if sorted(A)!=sorted(B): return False
    if A[0]!=B[0]: return False
    for i in range(1,N+1):
        if i not in primeset: continue
        if i*2<=N: continue
        if A[i-1]!=B[i-1]:
            return False
    else: return True

def main():
    T=int(input())
    ans=[]
    for _ in range(T):
        N=int(input())
        A=list(map(int,input().split()))
        B=list(map(int,input().split()))
        ans.append('Yes' if solve(N,A,B) else 'No')
    print(*ans,sep='\n')

main()
0