結果
問題 | No.1817 Reversed Edges |
ユーザー | U S |
提出日時 | 2022-01-21 21:54:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 477 ms / 2,000 ms |
コード長 | 1,501 bytes |
コンパイル時間 | 278 ms |
コンパイル使用メモリ | 87,148 KB |
実行使用メモリ | 124,552 KB |
最終ジャッジ日時 | 2023-08-17 05:48:36 |
合計ジャッジ時間 | 10,288 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
73,808 KB |
testcase_01 | AC | 116 ms
74,040 KB |
testcase_02 | AC | 118 ms
74,052 KB |
testcase_03 | AC | 119 ms
73,852 KB |
testcase_04 | AC | 118 ms
74,080 KB |
testcase_05 | AC | 118 ms
74,204 KB |
testcase_06 | AC | 118 ms
74,012 KB |
testcase_07 | AC | 426 ms
118,640 KB |
testcase_08 | AC | 278 ms
94,824 KB |
testcase_09 | AC | 432 ms
116,400 KB |
testcase_10 | AC | 292 ms
96,284 KB |
testcase_11 | AC | 355 ms
107,540 KB |
testcase_12 | AC | 477 ms
112,012 KB |
testcase_13 | AC | 443 ms
111,792 KB |
testcase_14 | AC | 468 ms
111,860 KB |
testcase_15 | AC | 474 ms
111,776 KB |
testcase_16 | AC | 464 ms
112,076 KB |
testcase_17 | AC | 433 ms
111,396 KB |
testcase_18 | AC | 433 ms
111,588 KB |
testcase_19 | AC | 454 ms
111,900 KB |
testcase_20 | AC | 457 ms
111,724 KB |
testcase_21 | AC | 456 ms
111,748 KB |
testcase_22 | AC | 275 ms
124,284 KB |
testcase_23 | AC | 285 ms
124,552 KB |
testcase_24 | AC | 269 ms
121,828 KB |
ソースコード
# import sys # input = sys.stdin.readline def mp():return map(int,input().split()) def lmp():return list(map(int,input().split())) def mps(A):return [tuple(map(int, input().split())) for _ in range(A)] def stoi(LIST):return list(map(int,LIST)) def itos(LIST):return list(map(str,LIST)) def bitA(X,A):return X & 1<<A == 1<<A import math import bisect import heapq import time from copy import copy as cc from copy import deepcopy as dc from itertools import accumulate, product from collections import Counter, defaultdict, deque def ceil(U,V):return (U+V-1)//V def modf1(N,MOD):return (N-1)%MOD+1 inf = int(1e18+20) mod = int(1e9+7) n = int(input()) edge = [[] for i in range(n)] for i in range(n-1): a,b = mp() a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) ans = [0]*n q = deque([0]) used = set() used.add(0) base = 0 while q: here = q.popleft() for i in edge[here]: if i not in used: q.append(i) used.add(i) if i < here:base += 1 ans[0] = base q = deque([0]) used = set() used.add(0) while q: here = q.popleft() for i in edge[here]: if i not in used: q.append(i) used.add(i) if i > here:ans[i] = ans[here] + 1 else:ans[i] = ans[here] - 1 for i in ans: print(i) # n = int(input()) # a = lmp() # a.sort(reverse=True) # ans = a[0] # for i in range(1,n): # if i % 2 == 1: # ans *= a[i] # else: # ans = ceil(ans, a[i]) # print(ans)