結果
| 問題 |
No.763 Noelちゃんと木遊び
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-04 12:08:19 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 792 bytes |
| コンパイル時間 | 3,135 ms |
| コンパイル使用メモリ | 252,124 KB |
| 実行使用メモリ | 29,924 KB |
| 最終ジャッジ日時 | 2024-11-25 22:57:47 |
| 合計ジャッジ時間 | 6,460 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
vector<bool> F(200010);
vector<vector<int>> G(200010);
vector DP(200010,vector<int>(2));
void DFS(int n, int v)
{
for(auto x : G[n])
{
if(F[x] || x == v) continue;
DFS(x,n);
DP[n][0] += max(DP[x][0],DP[x][1]+1);
DP[n][1] += max(DP[x][0],DP[x][1]);
}
return;
}
int main()
{
int N; cin >> N;
for(int i = 0; i < N-1; i++)
{
int A,B; cin >> A >> B;
G[A].push_back(B);
G[B].push_back(A);
}
DFS(1,-1);
cout << max(DP[1][0],DP[1][1])+1 << endl;
return 0;
}