結果

問題 No.1779 Magical Swap
ユーザー pluto77pluto77
提出日時 2022-02-24 16:41:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,161 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 23,272 KB
最終ジャッジ日時 2023-09-15 08:56:21
合計ジャッジ時間 6,196 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,012 KB
testcase_01 AC 15 ms
7,908 KB
testcase_02 AC 55 ms
8,064 KB
testcase_03 AC 19 ms
7,992 KB
testcase_04 AC 187 ms
21,028 KB
testcase_05 AC 80 ms
14,200 KB
testcase_06 AC 90 ms
14,788 KB
testcase_07 AC 157 ms
19,284 KB
testcase_08 AC 18 ms
8,496 KB
testcase_09 AC 54 ms
11,920 KB
testcase_10 AC 199 ms
21,792 KB
testcase_11 AC 101 ms
15,792 KB
testcase_12 AC 40 ms
10,736 KB
testcase_13 AC 151 ms
18,672 KB
testcase_14 AC 217 ms
23,152 KB
testcase_15 AC 1,161 ms
7,960 KB
testcase_16 AC 207 ms
23,272 KB
testcase_17 AC 130 ms
8,304 KB
testcase_18 AC 16 ms
8,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1779
import math
def isPrime(n):
 if n==2:
  return True
 if n%2==0:
  return False
 m=math.floor(math.sqrt(n))+1
 for p in range(3,m,2):
  if n%p==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