Submission #1074389


Source Code Expand

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;


vvi graph;
int ans = 0;
void dfs(int v, int depth) {
    int num = graph[v].size();
    chmax(ans, num+depth);

    tr(it, graph[v]) {
        dfs(*it, depth+1);
    }
}

int main() {
	int N;
	cin >> N;
    graph.resize(N);

    rep(i, N-1) {
        int a;
        cin >> a;
        a--;
        graph[a].push_back(i+1);
    }

    dfs(0, 0);

    cout << ans << endl;
	
    return 0;
}

Submission Info

Submission Time
Task B - Tournament
User palpal
Language C++11 (GCC 4.8.1)
Score 0
Code Size 3322 Byte
Status WA
Exec Time 25 ms
Memory 8832 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 3
AC × 33
WA × 20
Set Name Test Cases
Sample s1.txt, s2.txt, s3.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, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt WA 25 ms 4224 KB
02.txt WA 24 ms 4224 KB
03.txt WA 24 ms 4224 KB
04.txt WA 24 ms 4352 KB
05.txt AC 24 ms 4224 KB
06.txt WA 24 ms 4224 KB
07.txt AC 24 ms 4224 KB
08.txt AC 24 ms 4224 KB
09.txt AC 24 ms 4224 KB
10.txt WA 24 ms 4224 KB
11.txt AC 25 ms 8832 KB
12.txt AC 24 ms 7040 KB
13.txt AC 24 ms 6400 KB
14.txt AC 23 ms 5760 KB
15.txt AC 23 ms 5376 KB
16.txt AC 23 ms 4992 KB
17.txt WA 23 ms 4736 KB
18.txt AC 23 ms 4608 KB
19.txt WA 24 ms 4608 KB
20.txt AC 25 ms 4608 KB
21.txt AC 12 ms 3196 KB
22.txt AC 12 ms 3200 KB
23.txt AC 12 ms 3200 KB
24.txt AC 12 ms 3200 KB
25.txt AC 12 ms 3072 KB
26.txt AC 13 ms 3200 KB
27.txt AC 13 ms 3200 KB
28.txt AC 14 ms 3200 KB
29.txt AC 14 ms 3200 KB
30.txt AC 14 ms 3200 KB
31.txt WA 20 ms 4224 KB
32.txt WA 20 ms 3584 KB
33.txt WA 18 ms 3328 KB
34.txt WA 18 ms 3328 KB
35.txt WA 18 ms 3456 KB
36.txt WA 16 ms 3072 KB
37.txt WA 15 ms 3072 KB
38.txt WA 14 ms 3072 KB
39.txt WA 13 ms 3072 KB
40.txt WA 13 ms 2944 KB
41.txt WA 2 ms 256 KB
42.txt AC 2 ms 256 KB
43.txt AC 2 ms 256 KB
44.txt AC 2 ms 256 KB
45.txt AC 2 ms 256 KB
46.txt WA 2 ms 256 KB
47.txt AC 2 ms 256 KB
48.txt AC 2 ms 256 KB
49.txt AC 2 ms 256 KB
50.txt AC 2 ms 256 KB
s1.txt AC 2 ms 256 KB
s2.txt AC 2 ms 256 KB
s3.txt AC 2 ms 256 KB