Submission #1584285
Source Code Expand
#include <bits/stdc++.h> #define INF_MAX 2147483647 #define INF_MIN -2147483647 #define INF_LL 2000000000000000000LL #define INF 1000000000 #define EPS 1e-8 #define LL long long #define mod 1000000007 #define pb push_back #define mp make_pair #define f first #define s second #define setzero(a) memset(a,0,sizeof(a)) #define setdp(a) memset(a,-1,sizeof(a)) #define bits(a) __builtin_popcount(a) using namespace std; vector<int> nxt[100005]; int solve(int ind) { int ans = 0; vector<int> v; for (int x : nxt[ind]) { v.pb(solve(x)); } sort(v.begin(), v.end()); for (int i=0;i<v.size();i++) { ans = max(ans, v[i] + i + 1); } return ans; } int main() { int n, x; cin >> n; for (int i=1;i<n;i++) { scanf("%d", &x); nxt[x-1].pb(i); } cout << solve(0) - 1; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | AmrMahmoud |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 831 Byte |
Status | RE |
Exec Time | 105 ms |
Memory | 4096 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:39:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &x); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
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, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | RE | 96 ms | 2560 KB |
02.txt | RE | 97 ms | 2560 KB |
03.txt | RE | 97 ms | 2560 KB |
04.txt | RE | 98 ms | 2560 KB |
05.txt | RE | 97 ms | 2560 KB |
06.txt | RE | 97 ms | 2560 KB |
07.txt | RE | 97 ms | 2560 KB |
08.txt | RE | 97 ms | 2560 KB |
09.txt | RE | 100 ms | 2816 KB |
10.txt | RE | 97 ms | 2560 KB |
11.txt | RE | 105 ms | 2560 KB |
12.txt | RE | 98 ms | 2560 KB |
13.txt | WA | 21 ms | 4096 KB |
14.txt | RE | 98 ms | 2560 KB |
15.txt | WA | 2 ms | 2560 KB |
16.txt | WA | 2 ms | 2560 KB |
s1.txt | WA | 2 ms | 2560 KB |
s2.txt | WA | 2 ms | 2560 KB |