結果
問題 | No.2888 Mamehinata |
ユーザー |
![]() |
提出日時 | 2025-02-05 21:44:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,715 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 82,768 KB |
実行使用メモリ | 132,224 KB |
最終ジャッジ日時 | 2025-02-05 21:45:06 |
合計ジャッジ時間 | 20,805 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 WA * 7 |
ソースコード
import sys, math; sys.setrecursionlimit(10**8); sys.set_int_max_str_digits(0)inf = 1<<60; MOD = 998244353from bisect import bisect_left, bisect_rightfrom collections import deque, defaultdict, Counterfrom itertools import product, combinations, permutations, groupby, accumulatefrom heapq import heapify, heappop, heappushdef I(): return sys.stdin.readline().rstrip()def II(): return int(sys.stdin.readline().rstrip())def IS(): return sys.stdin.readline().rstrip().split()def MII(): return map(int, sys.stdin.readline().rstrip().split())def LI(): return list(sys.stdin.readline().rstrip())def TII(): return tuple(map(int, sys.stdin.readline().rstrip().split()))def LII(): return list(map(int, sys.stdin.readline().rstrip().split()))def LSI(): return list(map(str, sys.stdin.readline().rstrip().split()))def GMI(): return list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))def kiriage(a, b): return (a+b-1)//bN, M = map(int, input().split())G = [list() for _ in range(N)]for i in range(M):u, v = map(int, input().split())u -= 1v -= 1G[u].append(v)G[v].append(u)# BFSdist = [-1] * Ndist[0] = 0que = deque([0])while que:pos = que.popleft()for nex in G[pos]:if dist[nex] == -1:dist[nex] = dist[pos] + 1que.append(nex)# dist -> cntodd = [0] * (N + 1)even = [0] * (N + 1)for i in range(N):if dist[i] == -1:continueif dist[i]%2 == 0:even[dist[i]] += 1else:odd[dist[i]] += 1rui_odd = list(accumulate(odd))rui_even = list(accumulate(even))for i in range(1, N + 1):if i&1:ans = rui_odd[i]else:ans = rui_even[i]print(ans)