結果

問題 No.416 旅行会社
ユーザー ヒッキープログラミングするスレヒッキープログラミングするスレ
提出日時 2016-08-27 00:04:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 663 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 103,340 KB
最終ジャッジ日時 2024-04-26 04:12:23
合計ジャッジ時間 11,221 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def getInts():
    return list(map(int, input().split(' ')))

n, m, q = getInts()

f = [[] for _ in range(n + 1)]
e = [0] * (n + 1)

def sek(k):
    h = [1]
    while len(h) > 0:
        w = []
        for x in h:
            for y in f[x]:
                if e[y] < k:
                    e[y] = k
                    w.append(y)
        h = w

        
for _ in range(m):
    a, b = getInts()
    f[a].append(b)
    f[b].append(a)

sek(1)

for i in range(q):
    c, d = getInts()
    f[c].remove(d)
    f[d].remove(c)
    sek(i + 2)

for i in range(2, n + 1):
    if e[i] == 0:
        print(0)
    elif e[i] > q:
        print(-1)
    else:
        print(e[i])
0