結果
問題 | No.812 Change of Class |
ユーザー | terasa |
提出日時 | 2022-06-02 20:33:56 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,322 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 12,036 KB |
実行使用メモリ | 342,864 KB |
最終ジャッジ日時 | 2023-10-21 01:18:44 |
合計ジャッジ時間 | 132,883 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,180 ms
42,024 KB |
testcase_01 | AC | 300 ms
14,940 KB |
testcase_02 | AC | 1,113 ms
27,340 KB |
testcase_03 | AC | 2,592 ms
47,580 KB |
testcase_04 | AC | 2,256 ms
43,220 KB |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | AC | 43 ms
12,784 KB |
testcase_08 | AC | 36 ms
11,212 KB |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | AC | 96 ms
19,072 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 31 ms
10,272 KB |
testcase_14 | AC | 31 ms
10,272 KB |
testcase_15 | TLE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | TLE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | TLE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | RE | - |
testcase_35 | AC | 300 ms
13,072 KB |
testcase_36 | AC | 136 ms
11,284 KB |
testcase_37 | AC | 835 ms
15,772 KB |
testcase_38 | AC | 53 ms
13,872 KB |
testcase_39 | AC | 855 ms
15,784 KB |
testcase_40 | AC | 180 ms
12,028 KB |
testcase_41 | AC | 48 ms
13,248 KB |
testcase_42 | AC | 1,780 ms
20,964 KB |
testcase_43 | AC | 181 ms
18,036 KB |
testcase_44 | AC | 1,300 ms
17,996 KB |
testcase_45 | AC | 128 ms
11,280 KB |
testcase_46 | AC | 156 ms
17,748 KB |
testcase_47 | AC | 1,213 ms
18,072 KB |
testcase_48 | AC | 1,196 ms
19,904 KB |
testcase_49 | AC | 325 ms
12,668 KB |
testcase_50 | AC | 44 ms
10,400 KB |
testcase_51 | AC | 285 ms
13,860 KB |
testcase_52 | AC | 532 ms
18,600 KB |
testcase_53 | AC | 209 ms
11,928 KB |
testcase_54 | AC | 180 ms
11,524 KB |
testcase_55 | AC | 990 ms
19,316 KB |
testcase_56 | AC | 1,185 ms
20,952 KB |
testcase_57 | AC | 1,233 ms
21,644 KB |
testcase_58 | AC | 668 ms
16,288 KB |
testcase_59 | AC | 1,424 ms
23,112 KB |
testcase_60 | AC | 32 ms
10,268 KB |
testcase_61 | AC | 31 ms
10,268 KB |
testcase_62 | AC | 31 ms
10,268 KB |
ソースコード
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)