結果

問題 No.1779 Magical Swap
ユーザー ああいいああいい
提出日時 2021-12-28 16:26:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 27,648 KB
最終ジャッジ日時 2024-04-10 07:21:58
合計ジャッジ時間 5,006 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
12,416 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 83 ms
12,544 KB
testcase_04 AC 134 ms
25,144 KB
testcase_05 AC 100 ms
17,936 KB
testcase_06 AC 103 ms
18,692 KB
testcase_07 AC 123 ms
23,544 KB
testcase_08 AC 81 ms
12,672 KB
testcase_09 AC 106 ms
16,304 KB
testcase_10 AC 202 ms
26,128 KB
testcase_11 AC 144 ms
19,980 KB
testcase_12 AC 97 ms
14,976 KB
testcase_13 AC 179 ms
22,780 KB
testcase_14 AC 230 ms
25,916 KB
testcase_15 AC 1,122 ms
12,288 KB
testcase_16 AC 134 ms
27,648 KB
testcase_17 WA -
testcase_18 AC 76 ms
12,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

prime = set()
C = 10 ** 5 + 1
dat = [0] * C
i = 2
while i < C:
    if dat[i] == 0:
        prime.add(i)
        for j in range(i * 2,C,i):
            dat[j] = 1
    i += 1

for _ in range(T):
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    a = []
    b = []
    if A[0] != B[0]:
        print('No')
        continue
    flag = True
    for i in range(1,N):
        if (i+1) * 2 > N and i + 1 in prime:
            if A[i] != B[i]:
                flag = False
                break
        else:
            a.append(A[i])
            b.append(B[i])
    if flag:
        a.sort()
        b.sort()
        if a == b:
            print('Yes')
        else:
            print('No')
0