結果
| 問題 | No.1817 Reversed Edges | 
| コンテスト | |
| ユーザー |  MasKoaTS | 
| 提出日時 | 2022-01-21 22:20:23 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,091 bytes | 
| コンパイル時間 | 144 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 107,176 KB | 
| 最終ジャッジ日時 | 2024-11-26 00:50:11 | 
| 合計ジャッジ時間 | 22,619 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 21 TLE * 2 | 
ソースコード
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)
            
            
            
        