結果

問題 No.2319 Friends+
ユーザー flygonflygon
提出日時 2023-05-26 22:55:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,631 ms / 3,000 ms
コード長 814 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 192,612 KB
最終ジャッジ日時 2023-08-26 13:17:10
合計ジャッジ時間 46,525 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,472 KB
testcase_01 AC 71 ms
71,600 KB
testcase_02 AC 994 ms
189,928 KB
testcase_03 AC 966 ms
189,388 KB
testcase_04 AC 1,053 ms
192,612 KB
testcase_05 AC 976 ms
189,748 KB
testcase_06 AC 1,033 ms
190,380 KB
testcase_07 AC 1,507 ms
187,908 KB
testcase_08 AC 1,492 ms
187,700 KB
testcase_09 AC 1,489 ms
187,896 KB
testcase_10 AC 1,497 ms
188,004 KB
testcase_11 AC 1,505 ms
187,852 KB
testcase_12 AC 91 ms
75,452 KB
testcase_13 AC 91 ms
75,596 KB
testcase_14 AC 103 ms
76,872 KB
testcase_15 AC 94 ms
76,008 KB
testcase_16 AC 105 ms
77,676 KB
testcase_17 AC 69 ms
71,160 KB
testcase_18 AC 1,183 ms
187,500 KB
testcase_19 AC 1,033 ms
187,716 KB
testcase_20 AC 994 ms
187,768 KB
testcase_21 AC 1,000 ms
188,364 KB
testcase_22 AC 1,021 ms
187,864 KB
testcase_23 AC 1,631 ms
188,360 KB
testcase_24 AC 1,077 ms
187,896 KB
testcase_25 AC 1,066 ms
187,996 KB
testcase_26 AC 1,071 ms
187,816 KB
testcase_27 AC 1,048 ms
188,000 KB
testcase_28 AC 1,020 ms
188,532 KB
testcase_29 AC 1,019 ms
188,684 KB
testcase_30 AC 1,013 ms
187,828 KB
testcase_31 AC 1,015 ms
187,768 KB
testcase_32 AC 1,017 ms
188,416 KB
testcase_33 AC 1,001 ms
188,500 KB
testcase_34 AC 964 ms
187,488 KB
testcase_35 AC 939 ms
187,652 KB
testcase_36 AC 1,011 ms
187,768 KB
testcase_37 AC 736 ms
188,784 KB
testcase_38 AC 800 ms
188,724 KB
testcase_39 AC 789 ms
188,704 KB
testcase_40 AC 796 ms
189,156 KB
testcase_41 AC 789 ms
188,696 KB
testcase_42 AC 795 ms
188,584 KB
testcase_43 AC 796 ms
188,724 KB
testcase_44 AC 794 ms
189,276 KB
testcase_45 AC 776 ms
188,168 KB
testcase_46 AC 745 ms
187,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
p = list(map(int,input().split()))

graph = [[0]*(n//60+5) for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    graph[a][b//60] |= 1<<(b%60)
    graph[b][a//60] |= 1<<(a%60)

world = [[0]*(n//60 + 5) for i in range(n+1)]
for i in range(n):
    world[p[i]][i//60] |= 1<<(i%60)

q = int(input())
for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    wy = p[y]
    now = 0
    if p[x] == wy:
        print('No')
        continue
    ok = 0
    for j in range(n//60+5):
        if world[wy][j] & graph[x][j] != 0:
            ok = 1
            break
    if ok:
        print('Yes')
        world[p[x]][x//60] -= 1<<(x%60)
        world[p[y]][x//60] |= 1<<(x%60)
        p[x] = p[y]
    else:
        print('No') 

0