結果

問題 No.2427 Tree Distance Two
ユーザー kotatsugamekotatsugame
提出日時 2023-08-18 21:05:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 72,320 KB
実行使用メモリ 24,192 KB
最終ジャッジ日時 2024-05-06 02:33:42
合計ジャッジ時間 5,438 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,672 KB
testcase_01 AC 4 ms
12,672 KB
testcase_02 AC 4 ms
12,672 KB
testcase_03 AC 171 ms
22,272 KB
testcase_04 AC 5 ms
12,560 KB
testcase_05 AC 157 ms
22,364 KB
testcase_06 AC 4 ms
12,544 KB
testcase_07 AC 130 ms
23,020 KB
testcase_08 AC 152 ms
24,192 KB
testcase_09 AC 157 ms
23,040 KB
testcase_10 AC 155 ms
23,552 KB
testcase_11 AC 143 ms
23,564 KB
testcase_12 AC 143 ms
22,488 KB
testcase_13 AC 150 ms
22,428 KB
testcase_14 AC 104 ms
21,992 KB
testcase_15 AC 5 ms
12,544 KB
testcase_16 AC 4 ms
12,672 KB
testcase_17 AC 5 ms
12,544 KB
testcase_18 AC 5 ms
12,544 KB
testcase_19 AC 4 ms
12,520 KB
testcase_20 AC 7 ms
12,800 KB
testcase_21 AC 7 ms
12,920 KB
testcase_22 AC 6 ms
12,740 KB
testcase_23 AC 5 ms
12,612 KB
testcase_24 AC 6 ms
12,928 KB
testcase_25 AC 36 ms
15,104 KB
testcase_26 AC 89 ms
18,560 KB
testcase_27 AC 62 ms
16,896 KB
testcase_28 AC 146 ms
21,632 KB
testcase_29 AC 120 ms
20,480 KB
testcase_30 AC 92 ms
18,432 KB
testcase_31 AC 57 ms
16,512 KB
testcase_32 AC 86 ms
18,304 KB
testcase_33 AC 80 ms
17,664 KB
testcase_34 AC 24 ms
14,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
using namespace std;
int N;
vector<int>G[3<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=N;i++)
	{
		int ans=0;
		for(int v:G[i])ans+=G[v].size()-1;
		cout<<ans<<"\n";
	}
}
0