結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
mamumamura1
|
| 提出日時 | 2019-03-23 11:31:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,036 bytes |
| コンパイル時間 | 1,575 ms |
| コンパイル使用メモリ | 170,284 KB |
| 実行使用メモリ | 12,252 KB |
| 最終ジャッジ日時 | 2024-09-22 03:45:51 |
| 合計ジャッジ時間 | 3,786 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 18 |
ソースコード
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(111111);
ll po=0;
ll leng=0;
bool vis[111111];
void dfs(ll now,ll len){
if(len>leng){
leng=len;
po=now;
}
for(auto a:E[now]){
if(vis[a]==false){
vis[a]=true;
dfs(a,len+1);
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;cin>>n;
for(int i=0;i<n-1;i++){
ll a,b;cin>>a>>b;
--a;--b;
E[a].pb(b);
E[b].pb(a);
}
vis[0]=true;
dfs(0,0);
leng=0;
for(int i=0;i<111111;i++)vis[i]=false;
dfs(po,0);
cout<<n-1-leng<<endl;
return 0;
}
mamumamura1