結果

問題 No.2427 Tree Distance Two
ユーザー planesplanes
提出日時 2023-08-18 21:14:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 587 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 171,856 KB
実行使用メモリ 24,176 KB
最終ジャッジ日時 2024-05-06 02:54:09
合計ジャッジ時間 11,930 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 573 ms
21,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 587 ms
21,508 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 505 ms
22,496 KB
testcase_08 AC 533 ms
24,176 KB
testcase_09 AC 511 ms
21,968 KB
testcase_10 AC 533 ms
22,528 KB
testcase_11 AC 523 ms
23,428 KB
testcase_12 AC 522 ms
21,532 KB
testcase_13 AC 543 ms
21,552 KB
testcase_14 AC 430 ms
19,488 KB
testcase_15 AC 1 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 13 ms
5,376 KB
testcase_21 AC 15 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 13 ms
5,376 KB
testcase_25 AC 124 ms
8,064 KB
testcase_26 AC 320 ms
14,464 KB
testcase_27 AC 219 ms
11,392 KB
testcase_28 AC 501 ms
20,084 KB
testcase_29 AC 461 ms
17,920 KB
testcase_30 AC 315 ms
14,304 KB
testcase_31 AC 191 ms
10,368 KB
testcase_32 AC 317 ms
14,208 KB
testcase_33 AC 273 ms
12,672 KB
testcase_34 AC 76 ms
6,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
ll N;cin>>N;
vector<vector<ll>> vec(N,vector<ll> (0));
for(ll i=0;i<N-1;i++) {
  ll u,v;cin>>u>>v;
  u--;v--;
  vec[u].push_back(v);
  vec[v].push_back(u);
}

for(ll i=0;i<N;i++) {
  ll ans=0;
  for(auto x:vec[i]) {
    ans+=vec[x].size();
    ans--;
  }
  cout<<ans<<endl;
}
}
0