結果
| 問題 | No.763 Noelちゃんと木遊び |
| コンテスト | |
| ユーザー |
kriii
|
| 提出日時 | 2018-12-11 00:03:43 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 533 bytes |
| 記録 | |
| コンパイル時間 | 215 ms |
| コンパイル使用メモリ | 66,416 KB |
| 実行使用メモリ | 15,424 KB |
| 最終ジャッジ日時 | 2026-07-07 19:30:21 |
| 合計ジャッジ時間 | 1,921 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
int N;
vector<int> G[100100];
pair<int, int> go(int x, int l)
{
pair<int, int> res = {1,0};
for (auto &y : G[x]) if (y != l){
auto u = go(y,x);
res.first += max(u.first-1,u.second);
res.second += max(u.first,u.second);
}
return res;
}
int main()
{
scanf ("%d",&N);
for (int i=1;i<N;i++){
int x,y; scanf ("%d %d",&x,&y);
G[x].push_back(y);
G[y].push_back(x);
}
auto p = go(1,0);
printf ("%d\n",max(p.first,p.second));
return 0;
}
kriii