結果

問題 No.2319 Friends+
ユーザー mkawa2mkawa2
提出日時 2023-05-27 07:34:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,291 ms / 3,000 ms
コード長 1,188 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 312,004 KB
最終ジャッジ日時 2023-08-26 17:42:19
合計ジャッジ時間 79,445 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,296 KB
testcase_01 AC 71 ms
71,164 KB
testcase_02 AC 428 ms
106,180 KB
testcase_03 AC 428 ms
106,812 KB
testcase_04 AC 423 ms
106,360 KB
testcase_05 AC 424 ms
106,292 KB
testcase_06 AC 423 ms
106,628 KB
testcase_07 AC 2,291 ms
308,740 KB
testcase_08 AC 2,190 ms
309,276 KB
testcase_09 AC 2,089 ms
309,732 KB
testcase_10 AC 2,105 ms
308,936 KB
testcase_11 AC 2,071 ms
308,816 KB
testcase_12 AC 86 ms
75,980 KB
testcase_13 AC 87 ms
76,196 KB
testcase_14 AC 86 ms
76,208 KB
testcase_15 AC 88 ms
76,208 KB
testcase_16 AC 86 ms
76,320 KB
testcase_17 AC 73 ms
71,308 KB
testcase_18 AC 1,610 ms
289,252 KB
testcase_19 AC 2,159 ms
312,004 KB
testcase_20 AC 2,025 ms
309,736 KB
testcase_21 AC 2,013 ms
309,540 KB
testcase_22 AC 2,012 ms
309,600 KB
testcase_23 AC 2,229 ms
309,720 KB
testcase_24 AC 2,288 ms
310,600 KB
testcase_25 AC 2,164 ms
309,560 KB
testcase_26 AC 2,100 ms
310,180 KB
testcase_27 AC 2,105 ms
310,044 KB
testcase_28 AC 2,067 ms
309,576 KB
testcase_29 AC 2,003 ms
309,928 KB
testcase_30 AC 2,005 ms
309,492 KB
testcase_31 AC 1,968 ms
310,200 KB
testcase_32 AC 2,019 ms
309,668 KB
testcase_33 AC 2,050 ms
309,488 KB
testcase_34 AC 2,011 ms
309,536 KB
testcase_35 AC 2,092 ms
309,392 KB
testcase_36 AC 1,432 ms
277,136 KB
testcase_37 AC 1,085 ms
151,912 KB
testcase_38 AC 2,186 ms
309,776 KB
testcase_39 AC 2,234 ms
309,976 KB
testcase_40 AC 2,198 ms
309,576 KB
testcase_41 AC 2,176 ms
309,772 KB
testcase_42 AC 2,189 ms
309,492 KB
testcase_43 AC 2,100 ms
309,504 KB
testcase_44 AC 2,032 ms
309,540 KB
testcase_45 AC 1,706 ms
298,352 KB
testcase_46 AC 1,261 ms
230,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# md = 10**9+7
md = 998244353

n, m = LI()
pp = LI1()
to = [0]*n
for _ in range(m):
    u, v = LI1()
    to[u] |= 1 << v
    to[v] |= 1 << u

mem = [0]*n
for u, p in enumerate(pp): mem[p] |= 1 << u

for _ in range(II()):
    x, y = LI1()
    p, q = pp[x], pp[y]
    if p == q:
        print("No")
    else:
        if to[x] & mem[q]:
            print("Yes")
            mem[p] ^= 1 << x
            mem[q] ^= 1 << x
            pp[x] = q
        else:
            print("No")
0