結果
| 問題 |
No.812 Change of Class
|
| コンテスト | |
| ユーザー |
terasa
|
| 提出日時 | 2022-06-02 20:33:56 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,322 bytes |
| コンパイル時間 | 208 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 343,808 KB |
| 最終ジャッジ日時 | 2024-09-21 02:08:21 |
| 合計ジャッジ時間 | 97,109 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 RE * 25 |
ソースコード
import sys
# import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# pypyjit.set_param('max_unroll_recursion=-1')
def index_lt(a, x):
'return largest index s.t. A[i] < x or -1 if it does not exist'
return bisect.bisect_left(a, x) - 1
def index_le(a, x):
'return largest index s.t. A[i] <= x or -1 if it does not exist'
return bisect.bisect_right(a, x) - 1
def index_gt(a, x):
'return smallest index s.t. A[i] > x or len(a) if it does not exist'
return bisect.bisect_right(a, x)
def index_ge(a, x):
'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
return bisect.bisect_left(a, x)
N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
p, q = map(int, input().split())
p -= 1
q -= 1
E[p].append(q)
E[q].append(p)
Q = int(input())
for _ in range(Q):
s = int(input())
s -= 1
cnt = 0
depth = 0
def dfs(v, p, d):
global cnt, depth
cnt += 1
depth = max(depth, d)
for dest in E[v]:
if dest == p:
continue
dfs(dest, v, d + 1)
dfs(s, -1, 0)
print(cnt - 1, math.ceil(math.log2(depth)) if cnt > 2 else 0)
terasa