結果
問題 | No.2319 Friends+ |
ユーザー |
![]() |
提出日時 | 2023-10-05 00:44:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,319 ms / 3,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 357 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 314,404 KB |
最終ジャッジ日時 | 2024-07-26 14:56:41 |
合計ジャッジ時間 | 76,858 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 45 |
ソースコード
import sysinput = sys.stdin.readlineN,M=map(int,input().split())P=list(map(int,input().split()))for i in range(N):P[i]-=1Friends=[0]*Nfor i in range(M):a,b=map(int,input().split())a-=1b-=1Friends[a]|=1<<bFriends[b]|=1<<aRooms=[0]*Nfor i in range(N):x=P[i]Rooms[x]|=(1<<i)Q=int(input())for tests in range(Q):x,y=map(int,input().split())x-=1y-=1room=P[y]#print(P,Rooms,Friends)if P[x]==P[y] or Rooms[room] & Friends[x]==0:print("No")continueelse:print("Yes")mae=P[x]Rooms[mae]^=1<<xP[x]=P[y]Rooms[P[x]]^=1<<x