結果

問題 No.2427 Tree Distance Two
ユーザー 沙耶花沙耶花
提出日時 2023-08-18 21:10:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 722 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 3,899 ms
コンパイル使用メモリ 260,904 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2024-05-06 02:46:29
合計ジャッジ時間 16,442 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 698 ms
19,968 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 671 ms
20,096 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 635 ms
20,932 KB
testcase_08 AC 655 ms
22,144 KB
testcase_09 AC 645 ms
20,864 KB
testcase_10 AC 722 ms
21,376 KB
testcase_11 AC 623 ms
21,608 KB
testcase_12 AC 687 ms
20,536 KB
testcase_13 AC 661 ms
20,352 KB
testcase_14 AC 546 ms
19,584 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 18 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 157 ms
7,552 KB
testcase_26 AC 400 ms
13,696 KB
testcase_27 AC 297 ms
10,624 KB
testcase_28 AC 632 ms
18,816 KB
testcase_29 AC 550 ms
16,896 KB
testcase_30 AC 397 ms
13,440 KB
testcase_31 AC 231 ms
9,856 KB
testcase_32 AC 377 ms
13,312 KB
testcase_33 AC 369 ms
12,032 KB
testcase_34 AC 107 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

int main(){
	
	int n;
	cin>>n;
	vector<vector<int>> E(n);//E.resize(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	rep(i,n){
		int ans = 0;
		rep(j,E[i].size()){
			int to= E[i][j];
			ans += E[to].size()-1;
		}
		cout<<ans <<endl;
	}
	return 0;
}
0