結果

問題 No.2319 Friends+
ユーザー yupoohyupooh
提出日時 2023-05-26 23:41:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,247 ms / 3,000 ms
コード長 503 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 315,296 KB
最終ジャッジ日時 2023-08-26 14:02:39
合計ジャッジ時間 71,185 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,380 KB
testcase_01 AC 70 ms
71,416 KB
testcase_02 AC 358 ms
105,624 KB
testcase_03 AC 348 ms
105,544 KB
testcase_04 AC 349 ms
105,536 KB
testcase_05 AC 343 ms
105,656 KB
testcase_06 AC 348 ms
105,736 KB
testcase_07 AC 1,876 ms
314,688 KB
testcase_08 AC 1,877 ms
314,068 KB
testcase_09 AC 1,885 ms
313,372 KB
testcase_10 AC 1,875 ms
313,948 KB
testcase_11 AC 1,890 ms
313,804 KB
testcase_12 AC 77 ms
71,584 KB
testcase_13 AC 75 ms
71,268 KB
testcase_14 AC 75 ms
71,324 KB
testcase_15 AC 75 ms
71,276 KB
testcase_16 AC 75 ms
71,580 KB
testcase_17 AC 70 ms
71,392 KB
testcase_18 AC 1,470 ms
291,796 KB
testcase_19 AC 1,958 ms
311,988 KB
testcase_20 AC 1,866 ms
314,248 KB
testcase_21 AC 1,826 ms
314,220 KB
testcase_22 AC 1,818 ms
314,368 KB
testcase_23 AC 2,008 ms
315,296 KB
testcase_24 AC 2,064 ms
315,244 KB
testcase_25 AC 1,969 ms
314,516 KB
testcase_26 AC 1,944 ms
314,352 KB
testcase_27 AC 1,890 ms
314,212 KB
testcase_28 AC 1,853 ms
314,564 KB
testcase_29 AC 1,827 ms
314,352 KB
testcase_30 AC 1,828 ms
314,024 KB
testcase_31 AC 1,829 ms
314,224 KB
testcase_32 AC 1,842 ms
314,484 KB
testcase_33 AC 1,836 ms
314,360 KB
testcase_34 AC 1,878 ms
314,884 KB
testcase_35 AC 1,913 ms
314,292 KB
testcase_36 AC 1,258 ms
279,900 KB
testcase_37 AC 1,253 ms
174,308 KB
testcase_38 AC 2,179 ms
314,544 KB
testcase_39 AC 2,137 ms
314,252 KB
testcase_40 AC 2,171 ms
314,640 KB
testcase_41 AC 2,188 ms
314,328 KB
testcase_42 AC 2,247 ms
313,804 KB
testcase_43 AC 2,173 ms
314,088 KB
testcase_44 AC 2,089 ms
309,916 KB
testcase_45 AC 1,785 ms
293,548 KB
testcase_46 AC 1,445 ms
265,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
n,m=map(int,input().split())
p=list(map(int,input().split()))
fri=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  fri[a]^=1<<b
  fri[b]^=1<<a
wor=[0]*n
for i in range(n):
  p[i]-=1
  wor[p[i]]^=1<<i
q=int(input())
for _ in range(q):
  x,y=map(int,input().split())
  x-=1
  y-=1
  if p[x]==p[y]:
    print("No")
    continue
  if fri[x]&wor[p[y]]==0:
    print("No")
    continue
  wor[p[x]]^=1<<x
  wor[p[y]]^=1<<x
  p[x]=p[y]
  print("Yes")
0