AtCoder Grand Contest 009

Submission #1587229

Source codeソースコード

//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//


#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(ll (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

const int N = 200005;
int n,p[N],d[N];
vi adjL[N];

void dfs(int node,int dep) {
    
    vi vec;
    for(int ch:adjL[node])
        dfs(ch, dep+1) , vec.pb(d[ch]);


    sort(all(vec));
    for(int x:vec) d[node] = max(d[node]+1, x+1);
    
    
    
}


int main()
{
    scanf("%d",&n);
    lp(i, 2, n) scanf("%d",&p[i]) , adjL[p[i]].pb(i);
    dfs(1, 0);
    printf("%d\n",d[1]);
    return 0;
}
/*
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

Submission

Task問題 B - Tournament
User nameユーザ名 AhmedAbdellah
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 800
Source lengthソースコード長 3189 Byte
File nameファイル名
Exec time実行時間 28 ms
Memory usageメモリ使用量 17280 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:116:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:117:53: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
lp(i, 2, n) scanf("%d",&p[i]) , adjL[p[i]].pb(i);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt,s3.txt
All 800 / 800 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,s1.txt,s2.txt,s3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 27 ms 7936 KB
02.txt AC 27 ms 7936 KB
03.txt AC 28 ms 7936 KB
04.txt AC 27 ms 7936 KB
05.txt AC 27 ms 7936 KB
06.txt AC 27 ms 8064 KB
07.txt AC 27 ms 7936 KB
08.txt AC 27 ms 8064 KB
09.txt AC 27 ms 7936 KB
10.txt AC 27 ms 8064 KB
11.txt AC 28 ms 17280 KB
12.txt AC 27 ms 14464 KB
13.txt AC 26 ms 12928 KB
14.txt AC 26 ms 11392 KB
15.txt AC 26 ms 10368 KB
16.txt AC 26 ms 9472 KB
17.txt AC 25 ms 8960 KB
18.txt AC 25 ms 8576 KB
19.txt AC 26 ms 8448 KB
20.txt AC 26 ms 8320 KB
21.txt AC 12 ms 7544 KB
22.txt AC 12 ms 7264 KB
23.txt AC 12 ms 7156 KB
24.txt AC 12 ms 7168 KB
25.txt AC 13 ms 6912 KB
26.txt AC 13 ms 6912 KB
27.txt AC 13 ms 6912 KB
28.txt AC 12 ms 6912 KB
29.txt AC 13 ms 7040 KB
30.txt AC 14 ms 6912 KB
31.txt AC 22 ms 7936 KB
32.txt AC 22 ms 7424 KB
33.txt AC 19 ms 7168 KB
34.txt AC 20 ms 7168 KB
35.txt AC 19 ms 7296 KB
36.txt AC 16 ms 6912 KB
37.txt AC 15 ms 6784 KB
38.txt AC 13 ms 6912 KB
39.txt AC 13 ms 6912 KB
40.txt AC 12 ms 6784 KB
41.txt AC 3 ms 6400 KB
42.txt AC 3 ms 6400 KB
43.txt AC 3 ms 6400 KB
44.txt AC 3 ms 6400 KB
45.txt AC 3 ms 6400 KB
46.txt AC 3 ms 6400 KB
47.txt AC 3 ms 6400 KB
48.txt AC 3 ms 6400 KB
49.txt AC 3 ms 6400 KB
50.txt AC 3 ms 6400 KB
s1.txt AC 3 ms 6400 KB
s2.txt AC 3 ms 6400 KB
s3.txt AC 3 ms 6400 KB