結果

問題 No.1779 Magical Swap
ユーザー ramdosramdos
提出日時 2021-11-02 21:32:52
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,140 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 23,728 KB
最終ジャッジ日時 2023-09-23 07:28:16
合計ジャッジ時間 5,004 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,064 KB
testcase_01 AC 18 ms
7,996 KB
testcase_02 AC 56 ms
7,976 KB
testcase_03 AC 21 ms
7,984 KB
testcase_04 AC 258 ms
21,252 KB
testcase_05 AC 104 ms
14,352 KB
testcase_06 AC 118 ms
15,020 KB
testcase_07 AC 214 ms
19,436 KB
testcase_08 AC 21 ms
8,500 KB
testcase_09 AC 65 ms
11,944 KB
testcase_10 AC 267 ms
21,904 KB
testcase_11 AC 131 ms
15,932 KB
testcase_12 AC 50 ms
10,568 KB
testcase_13 AC 201 ms
18,740 KB
testcase_14 AC 309 ms
23,728 KB
testcase_15 AC 1,140 ms
7,988 KB
testcase_16 AC 287 ms
23,408 KB
testcase_17 AC 154 ms
8,304 KB
testcase_18 AC 17 ms
8,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def isPrime(n):
  if n == 1: return False
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

T=int(input())
for _ in range(T):
  N=int(input())
  a=list(map(int, input().split()))
  b=list(map(int, input().split()))
  flag=0
  for i in range(N):
    if (isPrime(i+1) and (i+1)*2>N) or i==0 :
      if(a[i]!=b[i]):
        flag=1
  if sorted(a)!=sorted(b):
    flag=1
  if flag==0:
    print("Yes")
  else:
    print("No")
0