#include "train.h"
using namespace std;
vector < int > Next[5005],Next2[5005],ans,P;
bool have1[5005][5005];
bool can[5005];
bool have2[5005];
bool F(int st,int here,int deg)
{
int t=0;
if(here==st&°) return 1;
if(have1[st][here]||P[here]) return 0;
have1[st][here]=1;
for(auto i:Next[here])
{
t=F(st,i,deg+1);
can[here]=can[here]||t;
if(t) break;
}
return t;
}
void F2(int here)
{
if(have2[here]) return;
have2[here]=1;
for(auto i:Next2[here]) F2(i);
}
vector < int > who_wins(vector < int > who, vector < int > power, vector < int > u, vector < int > v)
{
P=power;
int N=who.size(),M=u.size(),i;
for(i=0;i<N;i++) ans.push_back(0);
for(i=0;i<M;i++) Next[u[i]].push_back(v[i]);
for(i=0;i<M;i++) Next2[v[i]].push_back(u[i]);
for(i=0;i<N;i++) if(!power[i]) F(i,i,0);
for(i=0;i<N;i++) if(can[i]) F2(i);
for(i=0;i<N;i++) ans[i]=!have2[i];
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
11084 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
25156 KB |
Output is correct |
2 |
Correct |
56 ms |
22852 KB |
Output is correct |
3 |
Correct |
23 ms |
19256 KB |
Output is correct |
4 |
Incorrect |
416 ms |
23184 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
2508 KB |
Output is correct |
2 |
Correct |
163 ms |
25912 KB |
Output is correct |
3 |
Correct |
253 ms |
25808 KB |
Output is correct |
4 |
Correct |
50 ms |
16728 KB |
Output is correct |
5 |
Correct |
507 ms |
26004 KB |
Output is correct |
6 |
Correct |
402 ms |
25908 KB |
Output is correct |
7 |
Correct |
373 ms |
25624 KB |
Output is correct |
8 |
Correct |
175 ms |
24204 KB |
Output is correct |
9 |
Correct |
10 ms |
2636 KB |
Output is correct |
10 |
Correct |
14 ms |
7884 KB |
Output is correct |
11 |
Correct |
11 ms |
3684 KB |
Output is correct |
12 |
Correct |
16 ms |
8760 KB |
Output is correct |
13 |
Correct |
414 ms |
26052 KB |
Output is correct |
14 |
Correct |
289 ms |
26000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
563 ms |
25952 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
11084 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |