結果
| 問題 |
No.2319 Friends+
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 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 sys
input = sys.stdin.readline
N,M=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
P[i]-=1
Friends=[0]*N
for i in range(M):
a,b=map(int,input().split())
a-=1
b-=1
Friends[a]|=1<<b
Friends[b]|=1<<a
Rooms=[0]*N
for 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-=1
y-=1
room=P[y]
#print(P,Rooms,Friends)
if P[x]==P[y] or Rooms[room] & Friends[x]==0:
print("No")
continue
else:
print("Yes")
mae=P[x]
Rooms[mae]^=1<<x
P[x]=P[y]
Rooms[P[x]]^=1<<x
titia