結果

問題 No.1817 Reversed Edges
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-21 22:20:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,091 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 57,324 KB
最終ジャッジ日時 2023-08-17 06:30:45
合計ジャッジ時間 22,196 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
9,316 KB
testcase_01 AC 24 ms
9,448 KB
testcase_02 AC 24 ms
9,396 KB
testcase_03 AC 24 ms
9,400 KB
testcase_04 AC 24 ms
9,464 KB
testcase_05 AC 24 ms
9,304 KB
testcase_06 AC 25 ms
9,392 KB
testcase_07 AC 996 ms
55,844 KB
testcase_08 AC 470 ms
27,160 KB
testcase_09 AC 944 ms
44,280 KB
testcase_10 AC 547 ms
32,992 KB
testcase_11 AC 708 ms
36,400 KB
testcase_12 AC 1,170 ms
57,324 KB
testcase_13 AC 1,155 ms
57,056 KB
testcase_14 AC 1,149 ms
57,020 KB
testcase_15 AC 1,139 ms
57,016 KB
testcase_16 AC 1,134 ms
57,324 KB
testcase_17 AC 1,140 ms
57,056 KB
testcase_18 AC 1,165 ms
57,100 KB
testcase_19 AC 1,178 ms
57,024 KB
testcase_20 AC 1,138 ms
57,052 KB
testcase_21 AC 1,132 ms
57,120 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from copy import deepcopy as dcopy
import math
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline().rstrip()
def getN():
	return int(sys.stdin.readline())
def getNs():
	return map(int,sys.stdin.readline().split())
def getList():
	return list(map(int,sys.stdin.readline().split()))
def strinps(n):
	return [sys.stdin.readline().rstrip() for _ in range(n)]
pi = 3.141592653589793
mod = 10**9+7
MOD = 998244353
INF = math.inf
dx = [1,0,-1,0];	dy = [0,1,0,-1]


"""
Main Code
"""

n = getN()
route = [[] for _ in [0] * n]
d = {}
for _ in [0] * (n - 1):
	a,b = [i - 1 for i in getNs()]
	route[a].append(b)
	route[b].append(a)

def count(a, b):
	global d
	if((a, b) in d):
		return d[(a, b)]
	d[(a, b)] = 0
	for nv in route[b]:
		if(nv == a):
			continue
		d[(a, b)] += count(b, nv)
	d[(a, b)] += (a > b)
	return d[(a, b)]

for i in range(n):
	#print(d)
	ans = 0
	for nv in route[i]:
		#print((i, nv))
		ans += count(i, nv)
	print(ans)
0