Submission #1179759
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<tuple> #include<map> #include<set> #include<algorithm> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define MOD 1000000007 #define MAX 1000000001 #define INF 1410065408 using namespace std; typedef long long ll; typedef pair<ll, ll> P; struct edge{int from, to; ll cost;}; signed main(){ int N; cin >> N; vector<ll> dp(N+1, -1); vector<bool> flag(N, true); map<ll, ll> mp; rep(N-1){ cin >> mp[i+2]; flag[mp[i+2]] = false; } reppp(i, 1, N){ if(flag[i]){ dp[i] = 0; } } repp(k, N){ vector<bool> flag_copy(flag); reppp(i, 1, N){ if(flag[i]){ if(dp[mp[i]] == -1 || dp[mp[i]] < dp[i] + 1){ dp[mp[i]] = dp[i] + 1; }else{ dp[mp[i]]++; } flag_copy[i] = false; flag_copy[mp[i]] = true; } } swap(flag, flag_copy); bool finish = flag[1]; reppp(j, 2, N){ if(flag[j]){ finish = false; } } if(finish) break; } cout << dp[1]; }
Submission Info
Submission Time | |
---|---|
Task | B - Tournament |
User | Noimin |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1243 Byte |
Status | WA |
Exec Time | 2104 ms |
Memory | 9360 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 | 177 ms | 7296 KB |
02.txt | WA | 175 ms | 7296 KB |
03.txt | WA | 178 ms | 7296 KB |
04.txt | WA | 178 ms | 7296 KB |
05.txt | WA | 178 ms | 7296 KB |
06.txt | WA | 178 ms | 7296 KB |
07.txt | WA | 167 ms | 7296 KB |
08.txt | WA | 175 ms | 7296 KB |
09.txt | WA | 175 ms | 7296 KB |
10.txt | WA | 176 ms | 7296 KB |
11.txt | TLE | 2104 ms | 7296 KB |
12.txt | TLE | 2103 ms | 9360 KB |
13.txt | TLE | 2104 ms | 7296 KB |
14.txt | TLE | 2104 ms | 7296 KB |
15.txt | TLE | 2104 ms | 7296 KB |
16.txt | TLE | 2103 ms | 7296 KB |
17.txt | TLE | 2104 ms | 7296 KB |
18.txt | WA | 1931 ms | 9344 KB |
19.txt | WA | 723 ms | 7296 KB |
20.txt | WA | 481 ms | 7296 KB |
21.txt | AC | 137 ms | 7296 KB |
22.txt | AC | 140 ms | 7296 KB |
23.txt | AC | 139 ms | 7296 KB |
24.txt | WA | 139 ms | 7296 KB |
25.txt | WA | 141 ms | 7296 KB |
26.txt | WA | 142 ms | 7296 KB |
27.txt | WA | 142 ms | 7296 KB |
28.txt | WA | 148 ms | 7296 KB |
29.txt | WA | 152 ms | 7296 KB |
30.txt | WA | 163 ms | 7296 KB |
31.txt | WA | 145 ms | 7296 KB |
32.txt | WA | 149 ms | 7296 KB |
33.txt | WA | 147 ms | 7296 KB |
34.txt | WA | 150 ms | 7296 KB |
35.txt | AC | 146 ms | 7296 KB |
36.txt | AC | 147 ms | 7296 KB |
37.txt | WA | 145 ms | 7296 KB |
38.txt | WA | 145 ms | 7296 KB |
39.txt | WA | 141 ms | 7296 KB |
40.txt | WA | 142 ms | 7296 KB |
41.txt | AC | 1 ms | 256 KB |
42.txt | AC | 1 ms | 256 KB |
43.txt | AC | 1 ms | 256 KB |
44.txt | AC | 1 ms | 256 KB |
45.txt | AC | 1 ms | 256 KB |
46.txt | AC | 1 ms | 256 KB |
47.txt | AC | 1 ms | 256 KB |
48.txt | AC | 1 ms | 256 KB |
49.txt | AC | 1 ms | 256 KB |
50.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |