結果
問題 | No.812 Change of Class |
ユーザー | McGregorsh |
提出日時 | 2023-07-07 12:52:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,184 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 87,236 KB |
実行使用メモリ | 143,580 KB |
最終ジャッジ日時 | 2023-09-28 13:20:05 |
合計ジャッジ時間 | 38,785 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 267 ms
108,584 KB |
testcase_08 | AC | 252 ms
90,160 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 327 ms
143,580 KB |
testcase_12 | WA | - |
testcase_13 | AC | 240 ms
89,764 KB |
testcase_14 | AC | 239 ms
89,908 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 285 ms
112,688 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 288 ms
110,132 KB |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | AC | 420 ms
112,080 KB |
testcase_56 | AC | 447 ms
115,204 KB |
testcase_57 | AC | 464 ms
119,772 KB |
testcase_58 | AC | 369 ms
104,864 KB |
testcase_59 | AC | 493 ms
122,868 KB |
testcase_60 | AC | 252 ms
89,936 KB |
testcase_61 | AC | 250 ms
89,924 KB |
testcase_62 | AC | 246 ms
90,032 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 ans2 = 0 for i in range(N): if dist[i] > 0 and dist[i] != -INF: ans1 += 1 score = 0 if dist[i] % 2 == 0: score = dist[i] // 2 else: if dist[i] == 1: score = 0 else: score = dist[i] // 2 + 1 ans2 = max(ans2, score) print(ans1, ans2) if __name__ == '__main__': main()