結果

問題 No.1779 Magical Swap
ユーザー ああいいああいい
提出日時 2021-12-28 16:28:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,223 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 27,628 KB
最終ジャッジ日時 2024-04-10 07:24:00
合計ジャッジ時間 5,075 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
12,416 KB
testcase_01 AC 82 ms
12,416 KB
testcase_02 AC 116 ms
12,288 KB
testcase_03 AC 83 ms
12,544 KB
testcase_04 AC 134 ms
25,248 KB
testcase_05 AC 105 ms
17,936 KB
testcase_06 AC 105 ms
18,664 KB
testcase_07 AC 124 ms
23,548 KB
testcase_08 AC 82 ms
12,672 KB
testcase_09 AC 110 ms
16,044 KB
testcase_10 AC 215 ms
26,128 KB
testcase_11 AC 149 ms
20,024 KB
testcase_12 AC 102 ms
14,976 KB
testcase_13 AC 185 ms
22,912 KB
testcase_14 AC 225 ms
25,884 KB
testcase_15 AC 1,223 ms
12,416 KB
testcase_16 AC 144 ms
27,628 KB
testcase_17 AC 184 ms
12,288 KB
testcase_18 AC 80 ms
12,288 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
                print('No')
                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