結果
問題 | No.812 Change of Class |
ユーザー | McGregorsh |
提出日時 | 2023-07-07 13:09:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,110 ms / 4,000 ms |
コード長 | 2,161 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 136,320 KB |
最終ジャッジ日時 | 2024-07-21 08:18:19 |
合計ジャッジ時間 | 29,167 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 340 ms
107,160 KB |
testcase_01 | AC | 186 ms
90,752 KB |
testcase_02 | AC | 256 ms
100,864 KB |
testcase_03 | AC | 368 ms
112,000 KB |
testcase_04 | AC | 351 ms
108,416 KB |
testcase_05 | AC | 1,110 ms
110,336 KB |
testcase_06 | AC | 741 ms
105,984 KB |
testcase_07 | AC | 171 ms
106,364 KB |
testcase_08 | AC | 153 ms
89,088 KB |
testcase_09 | AC | 934 ms
113,560 KB |
testcase_10 | AC | 949 ms
116,352 KB |
testcase_11 | AC | 234 ms
136,320 KB |
testcase_12 | AC | 639 ms
119,808 KB |
testcase_13 | AC | 144 ms
88,320 KB |
testcase_14 | AC | 143 ms
88,320 KB |
testcase_15 | AC | 615 ms
107,904 KB |
testcase_16 | AC | 191 ms
89,984 KB |
testcase_17 | AC | 695 ms
107,392 KB |
testcase_18 | AC | 510 ms
103,552 KB |
testcase_19 | AC | 568 ms
104,704 KB |
testcase_20 | AC | 1,080 ms
114,816 KB |
testcase_21 | AC | 570 ms
103,040 KB |
testcase_22 | AC | 284 ms
99,072 KB |
testcase_23 | AC | 206 ms
90,240 KB |
testcase_24 | AC | 196 ms
89,472 KB |
testcase_25 | AC | 262 ms
97,408 KB |
testcase_26 | AC | 983 ms
109,568 KB |
testcase_27 | AC | 895 ms
107,264 KB |
testcase_28 | AC | 595 ms
106,368 KB |
testcase_29 | AC | 242 ms
90,240 KB |
testcase_30 | AC | 778 ms
106,368 KB |
testcase_31 | AC | 673 ms
102,912 KB |
testcase_32 | AC | 336 ms
99,968 KB |
testcase_33 | AC | 875 ms
110,592 KB |
testcase_34 | AC | 199 ms
89,984 KB |
testcase_35 | AC | 250 ms
99,200 KB |
testcase_36 | AC | 192 ms
89,984 KB |
testcase_37 | AC | 432 ms
99,072 KB |
testcase_38 | AC | 192 ms
110,464 KB |
testcase_39 | AC | 357 ms
101,760 KB |
testcase_40 | AC | 217 ms
90,496 KB |
testcase_41 | AC | 184 ms
107,520 KB |
testcase_42 | AC | 720 ms
104,960 KB |
testcase_43 | AC | 271 ms
121,728 KB |
testcase_44 | AC | 439 ms
104,192 KB |
testcase_45 | AC | 188 ms
90,112 KB |
testcase_46 | AC | 249 ms
120,960 KB |
testcase_47 | AC | 449 ms
103,808 KB |
testcase_48 | AC | 580 ms
104,960 KB |
testcase_49 | AC | 231 ms
91,008 KB |
testcase_50 | AC | 162 ms
88,832 KB |
testcase_51 | AC | 280 ms
101,376 KB |
testcase_52 | AC | 406 ms
109,076 KB |
testcase_53 | AC | 224 ms
90,368 KB |
testcase_54 | AC | 202 ms
90,544 KB |
testcase_55 | AC | 320 ms
110,592 KB |
testcase_56 | AC | 346 ms
113,280 KB |
testcase_57 | AC | 356 ms
114,560 KB |
testcase_58 | AC | 261 ms
101,832 KB |
testcase_59 | AC | 400 ms
125,404 KB |
testcase_60 | AC | 141 ms
88,448 KB |
testcase_61 | AC | 149 ms
88,320 KB |
testcase_62 | AC | 146 ms
88,320 KB |
ソースコード
import sys from sys import stdin from fractions import Fraction import math from math import ceil, floor, sqrt, pi, factorial, gcd from copy import deepcopy from collections import Counter, deque, defaultdict from heapq import heapify, heappop, heappush from itertools import accumulate, product, combinations, combinations_with_replacement, permutations from bisect import bisect, bisect_left, bisect_right from functools import reduce, lru_cache from decimal import Decimal, getcontext, ROUND_HALF_UP def i_input(): return int(stdin.readline()) def i_map(): return map(int, stdin.readline().split()) def i_list(): return list(i_map()) def s_input(): return stdin.readline()[:-1] def s_map(): return s_input().split() def s_list(): return list(s_map()) def lcm(a, b): return a * b // gcd(a, b) def get_distance(x1, y1, x2, y2): d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) return d def rotate(table): n_fild = [] for x in zip(*table[::-1]): n_fild.append(x) return n_fild sys.setrecursionlimit(10 ** 7) INF = float('inf') MOD = 10 ** 9 + 7 MOD2 = 998244353 alpa = 'abcdefghijklmnopqrstuvwxyz' ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def main(): N, M = i_map() nums = [[] for i in range(N)] for i in range(M): a, b = i_map() a -= 1 b -= 1 nums[a].append(b) nums[b].append(a) Q = int(input()) for i in range(Q): p = int(input()) p -= 1 dist = [-INF] * N dist[p] = 0 que = deque() que.append(p) while que: now = que.popleft() for nxt in nums[now]: if dist[nxt] == -INF: dist[nxt] = dist[now] + 1 que.append(nxt) ans1 = 0 for j in range(N): if dist[j] > 0 and dist[j] != -INF: ans1 += 1 maxnum = max(dist) if maxnum == 1: ans2 = 0 else: ans2 = 0 for k in range(100): l = 2 ** k r = 2 ** (k+1) if k < maxnum <= r: ans2 = k+1 break print(ans1, ans2) if __name__ == '__main__': main()