結果
問題 | No.812 Change of Class |
ユーザー |
![]() |
提出日時 | 2019-04-12 21:59:37 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 842 bytes |
コンパイル時間 | 135 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 51,948 KB |
最終ジャッジ日時 | 2024-06-12 07:14:58 |
合計ジャッジ時間 | 10,899 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 59 |
ソースコード
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime,random sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) N,M = inpl() lines = defaultdict(set) for i in range(M): p,q = inpl() p,q = p-1,q-1 lines[p].add(q) lines[q].add(p) Q = int(input()) for i in range(Q): A = int(input()) A -= 1 q = queue.Queue() q.put([A,0]) link = [0]*N tmp = 0 while not q.empty(): s,depth = q.get() if link[s] == 0: link[s] = 1 for t in lines[s]: q.put([t,depth+1]) tmp = max(tmp,depth) if tmp <= 1: print(sum(link)-1,0) else: print(sum(link)-1,(tmp+1)//2)