結果
問題 | No.812 Change of Class |
ユーザー |
![]() |
提出日時 | 2020-06-21 18:14:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 935 bytes |
コンパイル時間 | 119 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 60,204 KB |
最終ジャッジ日時 | 2024-07-03 18:10:50 |
合計ジャッジ時間 | 21,206 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | WA * 5 TLE * 1 -- * 54 |
ソースコード
import heapqdef dijkstra(s):inf = 10**9d = [inf]*(N+1)used = [0]*(N+1)h = [(0, s)]while h:temp = heapq.heappop(h)dist = temp[0]u = temp[1]if used[u] == 1:continueused[u] = 1d[u] = distfor v in E[u]:if used[v] == 1:continueheapq.heappush(h, (dist+1, v))return dN,M = map(int, input().split())E = [[] for _ in range(N+1)]for _ in range(M):p,q = map(int, input().split())E[p].append(q)E[q].append(p)Q = int(input())for _ in range(Q):a = int(input())d = dijkstra(a)num = -1cnt = 0for i in range(1, N+1):if d[i] == 10**9:continuecnt = max(cnt, d[i]-1)num += 1day = 0for i in range(1, cnt+1):if i*(i-1)//2 < cnt <= i*(i+1)//2:day = ibreakprint(num, day)