Submission #2159336


Source Code Expand

//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(15) << x; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=2e5+5,LG=32,SM=2e4+5,inf=1e9+5;
ll mod=1e9+7;
#define MOK(x) if(x>mod) x-=mod;
ll pw(ll x,ll n) { return (n==0?1:pw(x*x%mod,n/2)*(n&1?x:1)%mod); }

ll n;
vll g[M];
ll cm[M],cn[M];
ll res;

ll lasb(ll x) { return (x<2?x:lasb(x>>1)+1); }
ll firb(ll x) { return (x&1?0:firb(x>>1)+1); }

void dfs(ll x,ll p)
{
    ll ba=0;
    for (ll y:g[x])
    {
        if (y==p) continue;
        dfs(y,x);
        ba|=cm[x]&cm[y];
        cm[x]|=cm[y];
    }
    ll nd=lasb(ba);
    cm[x]&=-(1<<nd);
    cm[x]+=(1<<nd);
    cn[x]=firb(cm[x]);
    smax(res,cn[x]);
}
 
int main()
{
	ios::sync_with_stdio(0);
    cin >> n;
    For(i,1,n)
    {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        g[a].PB(b);g[b].PB(a);
    }
    dfs(0,0);
    RET(res);
} 

Submission Info

Submission Time
Task D - Uninity
User hamid_k
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 2325 Byte
Status AC
Exec Time 47 ms
Memory 14976 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1400 / 1400
Status
AC × 2
AC × 74
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 38 ms 11008 KB
02.txt AC 38 ms 11008 KB
03.txt AC 38 ms 11008 KB
04.txt AC 38 ms 11008 KB
05.txt AC 40 ms 11008 KB
06.txt AC 38 ms 11008 KB
07.txt AC 38 ms 11008 KB
08.txt AC 38 ms 11008 KB
09.txt AC 27 ms 11520 KB
10.txt AC 27 ms 12800 KB
11.txt AC 15 ms 9344 KB
12.txt AC 15 ms 9472 KB
13.txt AC 40 ms 14976 KB
14.txt AC 37 ms 14464 KB
15.txt AC 47 ms 14464 KB
16.txt AC 40 ms 12544 KB
17.txt AC 30 ms 11248 KB
18.txt AC 30 ms 11240 KB
19.txt AC 30 ms 11372 KB
20.txt AC 29 ms 11264 KB
21.txt AC 33 ms 11264 KB
22.txt AC 33 ms 11264 KB
23.txt AC 29 ms 11252 KB
24.txt AC 30 ms 11252 KB
25.txt AC 33 ms 11000 KB
26.txt AC 39 ms 11136 KB
27.txt AC 38 ms 11136 KB
28.txt AC 36 ms 11136 KB
29.txt AC 38 ms 11136 KB
30.txt AC 41 ms 11136 KB
31.txt AC 41 ms 11136 KB
32.txt AC 37 ms 11008 KB
33.txt AC 39 ms 11008 KB
34.txt AC 38 ms 11008 KB
35.txt AC 38 ms 11008 KB
36.txt AC 38 ms 11008 KB
37.txt AC 38 ms 11008 KB
38.txt AC 38 ms 10880 KB
39.txt AC 38 ms 10880 KB
40.txt AC 38 ms 11136 KB
41.txt AC 38 ms 11136 KB
42.txt AC 40 ms 11008 KB
43.txt AC 39 ms 11008 KB
44.txt AC 33 ms 11520 KB
45.txt AC 33 ms 11520 KB
46.txt AC 35 ms 11520 KB
47.txt AC 35 ms 11520 KB
48.txt AC 36 ms 11392 KB
49.txt AC 36 ms 11392 KB
50.txt AC 38 ms 11136 KB
51.txt AC 38 ms 11136 KB
52.txt AC 39 ms 10880 KB
53.txt AC 39 ms 10880 KB
54.txt AC 39 ms 11008 KB
55.txt AC 39 ms 11008 KB
56.txt AC 30 ms 11252 KB
57.txt AC 36 ms 13944 KB
58.txt AC 36 ms 13944 KB
59.txt AC 39 ms 10496 KB
60.txt AC 38 ms 10496 KB
61.txt AC 31 ms 12144 KB
62.txt AC 32 ms 12144 KB
63.txt AC 3 ms 6016 KB
64.txt AC 3 ms 6016 KB
65.txt AC 3 ms 6016 KB
66.txt AC 3 ms 6016 KB
67.txt AC 3 ms 6016 KB
68.txt AC 3 ms 6016 KB
69.txt AC 3 ms 6016 KB
70.txt AC 3 ms 6016 KB
71.txt AC 3 ms 6016 KB
72.txt AC 3 ms 6016 KB
s1.txt AC 3 ms 6016 KB
s2.txt AC 3 ms 6016 KB