結果
問題 | No.812 Change of Class |
ユーザー | McGregorsh |
提出日時 | 2023-07-07 12:52:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,184 bytes |
コンパイル時間 | 192 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 136,064 KB |
最終ジャッジ日時 | 2024-07-21 07:57:42 |
合計ジャッジ時間 | 33,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 185 ms
105,984 KB |
testcase_08 | AC | 161 ms
88,832 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 233 ms
136,064 KB |
testcase_12 | WA | - |
testcase_13 | AC | 184 ms
88,192 KB |
testcase_14 | AC | 167 ms
88,320 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 | 198 ms
110,080 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 220 ms
107,008 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 | 332 ms
109,952 KB |
testcase_56 | AC | 352 ms
113,152 KB |
testcase_57 | AC | 370 ms
114,432 KB |
testcase_58 | AC | 268 ms
101,248 KB |
testcase_59 | AC | 408 ms
125,440 KB |
testcase_60 | AC | 162 ms
88,576 KB |
testcase_61 | AC | 153 ms
87,936 KB |
testcase_62 | AC | 155 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 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()