Submission #1074372
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(int i = (l) ; i < (r); i++)
#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define FOR(i, v) for(auto i = v.begin(); i != v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
os << "[";
FOR(it, v) {
if(it != v.begin()) { os << ", "; }
os << *it;
}
os << "]";
return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
os << "<" << p.FI << ", " << p.SE << ">";
return os;
}
// ---- ----
int n, a[100000];
int b[100000], win[100000];
bool vis[100000];
int num[100000];
int search(int i, int x) {
if(i == 1) { return x + 1; }
if(vis[i]) { return num[i]; }
vis[i] = true;
num[i] = search(a[i], x + 1);
return num[i];
}
int main() {
cin >> n;
incII(i, 2, n) { cin >> a[i]; }
int ma = 0;
incII(i, 2, n) { b[ a[i] ] = i; }
incII(i, 2, n) { win[ a[i] ]++; }
incII(i, 2, n) { setmax(ma, search(i, win[i])); }
cout << ma << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Tournament |
User |
FF256grhy |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2226 Byte |
Status |
WA |
Exec Time |
37 ms |
Memory |
1920 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 800 |
Status |
|
|
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 |
36 ms |
1920 KB |
02.txt |
WA |
36 ms |
1920 KB |
03.txt |
WA |
36 ms |
1920 KB |
04.txt |
WA |
36 ms |
1920 KB |
05.txt |
WA |
35 ms |
1920 KB |
06.txt |
WA |
36 ms |
1920 KB |
07.txt |
WA |
34 ms |
640 KB |
08.txt |
WA |
37 ms |
1920 KB |
09.txt |
WA |
36 ms |
1920 KB |
10.txt |
WA |
36 ms |
1920 KB |
11.txt |
WA |
36 ms |
1920 KB |
12.txt |
WA |
37 ms |
1920 KB |
13.txt |
WA |
37 ms |
1920 KB |
14.txt |
WA |
37 ms |
1920 KB |
15.txt |
WA |
36 ms |
1920 KB |
16.txt |
WA |
37 ms |
1920 KB |
17.txt |
WA |
36 ms |
1920 KB |
18.txt |
WA |
37 ms |
1920 KB |
19.txt |
WA |
36 ms |
1920 KB |
20.txt |
WA |
36 ms |
1920 KB |
21.txt |
WA |
23 ms |
640 KB |
22.txt |
WA |
25 ms |
1152 KB |
23.txt |
WA |
24 ms |
1152 KB |
24.txt |
WA |
24 ms |
1152 KB |
25.txt |
WA |
24 ms |
1152 KB |
26.txt |
WA |
26 ms |
1152 KB |
27.txt |
WA |
27 ms |
1152 KB |
28.txt |
WA |
25 ms |
640 KB |
29.txt |
WA |
29 ms |
1152 KB |
30.txt |
WA |
30 ms |
1152 KB |
31.txt |
WA |
36 ms |
1536 KB |
32.txt |
WA |
35 ms |
1408 KB |
33.txt |
WA |
35 ms |
1280 KB |
34.txt |
WA |
35 ms |
1280 KB |
35.txt |
WA |
32 ms |
768 KB |
36.txt |
WA |
33 ms |
1152 KB |
37.txt |
WA |
32 ms |
1152 KB |
38.txt |
WA |
30 ms |
1152 KB |
39.txt |
WA |
29 ms |
1152 KB |
40.txt |
WA |
27 ms |
1152 KB |
41.txt |
WA |
3 ms |
256 KB |
42.txt |
WA |
3 ms |
256 KB |
43.txt |
AC |
2 ms |
256 KB |
44.txt |
WA |
3 ms |
256 KB |
45.txt |
AC |
2 ms |
256 KB |
46.txt |
WA |
2 ms |
256 KB |
47.txt |
WA |
3 ms |
256 KB |
48.txt |
WA |
2 ms |
256 KB |
49.txt |
WA |
2 ms |
256 KB |
50.txt |
WA |
3 ms |
256 KB |
s1.txt |
AC |
3 ms |
256 KB |
s2.txt |
AC |
3 ms |
256 KB |
s3.txt |
AC |
3 ms |
256 KB |