Submission #1390489
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=5e5+5,M=2e6+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n,m,bin[30]={1};
int head[N],cnt,lg[N];
struct edge{int t,ne;}e[N];
void adde(int a,int b){e[++cnt]=(edge){b,head[a]};head[a]=cnt;}
#define pw(a) (1<<(a))
int gao(int x,int f){
int S=0,K=0,P=0,res=0;
run(x)if(v!=f){
K=gao(v,x);
S|=K&P;
P|=K;
}
res=(P|(pw(lg[S]+1)-1))+1;
return res;
}
int main(){
read(n);
re(i,1,n){int a,b;read(a,b);adde(a,b);adde(b,a);}
lg[0]=-1;rep(i,1,1<<17)lg[i]=lg[i>>1]+1;
cout<<lg[gao(1,0)];
}
Submission Info
Submission Time |
|
Task |
D - Uninity |
User |
xjt |
Language |
C++14 (GCC 5.4.1) |
Score |
1400 |
Code Size |
2375 Byte |
Status |
AC |
Exec Time |
19 ms |
Memory |
9472 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1400 / 1400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt, 68.txt, 69.txt, 70.txt, 71.txt, 72.txt, s1.txt, s2.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
14 ms |
6016 KB |
02.txt |
AC |
16 ms |
6016 KB |
03.txt |
AC |
16 ms |
6016 KB |
04.txt |
AC |
15 ms |
6016 KB |
05.txt |
AC |
15 ms |
6016 KB |
06.txt |
AC |
14 ms |
6016 KB |
07.txt |
AC |
15 ms |
6016 KB |
08.txt |
AC |
15 ms |
6016 KB |
09.txt |
AC |
12 ms |
7168 KB |
10.txt |
AC |
14 ms |
8192 KB |
11.txt |
AC |
7 ms |
6144 KB |
12.txt |
AC |
7 ms |
6272 KB |
13.txt |
AC |
17 ms |
9472 KB |
14.txt |
AC |
16 ms |
9216 KB |
15.txt |
AC |
19 ms |
8704 KB |
16.txt |
AC |
18 ms |
7168 KB |
17.txt |
AC |
13 ms |
6016 KB |
18.txt |
AC |
13 ms |
6016 KB |
19.txt |
AC |
13 ms |
6016 KB |
20.txt |
AC |
13 ms |
6016 KB |
21.txt |
AC |
13 ms |
6016 KB |
22.txt |
AC |
13 ms |
6016 KB |
23.txt |
AC |
12 ms |
6016 KB |
24.txt |
AC |
12 ms |
6016 KB |
25.txt |
AC |
13 ms |
6016 KB |
26.txt |
AC |
14 ms |
6016 KB |
27.txt |
AC |
14 ms |
6016 KB |
28.txt |
AC |
14 ms |
6016 KB |
29.txt |
AC |
14 ms |
6016 KB |
30.txt |
AC |
14 ms |
6016 KB |
31.txt |
AC |
14 ms |
6016 KB |
32.txt |
AC |
14 ms |
6016 KB |
33.txt |
AC |
14 ms |
6016 KB |
34.txt |
AC |
15 ms |
6016 KB |
35.txt |
AC |
15 ms |
6016 KB |
36.txt |
AC |
16 ms |
6016 KB |
37.txt |
AC |
15 ms |
6016 KB |
38.txt |
AC |
15 ms |
6016 KB |
39.txt |
AC |
15 ms |
6016 KB |
40.txt |
AC |
15 ms |
6016 KB |
41.txt |
AC |
15 ms |
6016 KB |
42.txt |
AC |
15 ms |
6016 KB |
43.txt |
AC |
17 ms |
6016 KB |
44.txt |
AC |
14 ms |
6016 KB |
45.txt |
AC |
14 ms |
6016 KB |
46.txt |
AC |
14 ms |
6016 KB |
47.txt |
AC |
14 ms |
6016 KB |
48.txt |
AC |
14 ms |
6144 KB |
49.txt |
AC |
14 ms |
6016 KB |
50.txt |
AC |
15 ms |
6144 KB |
51.txt |
AC |
15 ms |
6144 KB |
52.txt |
AC |
15 ms |
6016 KB |
53.txt |
AC |
15 ms |
6144 KB |
54.txt |
AC |
16 ms |
6144 KB |
55.txt |
AC |
17 ms |
6144 KB |
56.txt |
AC |
13 ms |
6016 KB |
57.txt |
AC |
16 ms |
8320 KB |
58.txt |
AC |
15 ms |
8320 KB |
59.txt |
AC |
16 ms |
6144 KB |
60.txt |
AC |
17 ms |
6144 KB |
61.txt |
AC |
14 ms |
6784 KB |
62.txt |
AC |
14 ms |
6784 KB |
63.txt |
AC |
2 ms |
4352 KB |
64.txt |
AC |
2 ms |
4352 KB |
65.txt |
AC |
2 ms |
4352 KB |
66.txt |
AC |
2 ms |
4352 KB |
67.txt |
AC |
2 ms |
4352 KB |
68.txt |
AC |
2 ms |
4352 KB |
69.txt |
AC |
2 ms |
4352 KB |
70.txt |
AC |
2 ms |
4352 KB |
71.txt |
AC |
2 ms |
4352 KB |
72.txt |
AC |
2 ms |
4352 KB |
s1.txt |
AC |
2 ms |
4352 KB |
s2.txt |
AC |
2 ms |
4352 KB |