Submission #1437932
Source Code Expand
#include<iostream> #include<cstdio> #include<vector> #include<set> using namespace std; int a,b,c,i,j,k,ind[100009],p[100009],count; int main(){ cin>>a; for(i=2;i<=a;i++){ cin>>b; ind[b]++; p[i]=b; } int vi[100009]; for(i=1;i<=a;i++){ vi[i]=1; } while(true){ vector<int> q; for(j=2;j<=a;j++){ if(ind[j]==0&&vi[p[j]]==1){ // ind[j]=-1; vi[p[j]]=0; q.push_back(j); } } if(q.size()==0){ cout<<count<<endl; return 0; }else{ count++; } for(j=0;j<q.size();j++){ // if(vi[p[q[j]]]){ vi[p[q[j]]]=1; ind[p[q[j]]]--; ind[q[j]]=-1; // }//else cout<<q[j]<<endl; // ind[p[q[j]]]--; } } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | kk2048 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 700 Byte |
Status | RE |
Exec Time | 2103 ms |
Memory | 1692 KB |
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 | 100 ms | 256 KB |
02.txt | RE | 97 ms | 256 KB |
03.txt | RE | 96 ms | 256 KB |
04.txt | RE | 101 ms | 256 KB |
05.txt | RE | 96 ms | 256 KB |
06.txt | RE | 98 ms | 256 KB |
07.txt | RE | 104 ms | 256 KB |
08.txt | RE | 97 ms | 256 KB |
09.txt | RE | 95 ms | 256 KB |
10.txt | RE | 96 ms | 256 KB |
11.txt | WA | 35 ms | 1692 KB |
12.txt | TLE | 2103 ms | 1152 KB |
13.txt | WA | 35 ms | 1692 KB |
14.txt | RE | 96 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 1 ms | 256 KB |
s1.txt | WA | 1 ms | 256 KB |
s2.txt | WA | 1 ms | 256 KB |