結果
問題 | No.1390 Get together |
ユーザー | kojihashimoto-kobe |
提出日時 | 2021-03-25 17:01:47 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 401 ms |
コンパイル使用メモリ | 87,116 KB |
実行使用メモリ | 113,932 KB |
最終ジャッジ日時 | 2023-08-18 00:58:50 |
合計ジャッジ時間 | 6,994 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 97 ms
76,252 KB |
testcase_01 | AC | 96 ms
71,400 KB |
testcase_02 | AC | 93 ms
71,440 KB |
testcase_03 | AC | 154 ms
79,316 KB |
testcase_04 | AC | 153 ms
79,032 KB |
testcase_05 | AC | 153 ms
79,112 KB |
testcase_06 | AC | 152 ms
79,024 KB |
testcase_07 | AC | 150 ms
79,440 KB |
testcase_08 | AC | 155 ms
79,216 KB |
testcase_09 | AC | 159 ms
79,040 KB |
testcase_10 | AC | 99 ms
71,512 KB |
testcase_11 | AC | 99 ms
71,244 KB |
testcase_12 | AC | 98 ms
71,516 KB |
testcase_13 | AC | 99 ms
71,396 KB |
testcase_14 | AC | 98 ms
71,484 KB |
testcase_15 | AC | 97 ms
71,396 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
n, m = map(int, input().split()) from collections import deque #色iのスライムがどの箱に入っているかを管理 color = [[] for _ in range(n+1)] #箱iにどの色のスライムが入っているかを管理 box = [[] for _ in range(m+1)] for i in range(n): b, c = map(int, input().split()) box[b].append(c) color[c].append(b) #アクセス済みの箱を管理 dist = [-1] * (m+1) dist[0] = 0 ans = 0 for i in range(m+1): if dist[i] == -1: dist[i] = 0 d = deque() d.append(i) while d: v = d.popleft() for j in box[v]: for k in color[j]: if dist[k] != -1: continue dist[k] = dist[v] + 1 d.append(k) ans += 1 print(ans)