#include<bits/stdc++.h>
#include "train.h"
using namespace std;
const int nax = 5000;
int n, m;
vector<int>g[nax], gt[nax];
vector<int>A, R;
vector<int>cr(nax, -1);
vector<int>stk;
bool cyc[nax];
int vis[nax];
void solve(int v) {
cr[v] = stk.size();
stk.push_back(v);
vis[v] = 1;
for(int u : g[v]) {
if(cr[u]==-1) {
if(vis[u]!=2) solve(u);
} else {
for(int j=stk.size()-1; j>=cr[u]; --j) {
cyc[stk[j]] = true;
}
}
}
cr[v] = -1;
stk.pop_back();
vis[v] = 2;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size(), m = u.size();
for(int i=0; i<m; ++i) {
g[u[i]].push_back(v[i]);
gt[v[i]].push_back(u[i]);
}
A = a, R = r;
vector<int>res(n);
for(int i=0; i<n; ++i) if(vis[i]==0) {
solve(i);
}
queue<int>q;
for(int i=0; i<n; ++i) if(R[i] && cyc[i]) {
q.push(i);
res[i] = 1;
}
while(!q.empty()) {
int v = q.front(); q.pop();
for(int u : gt[v]) if(res[u]!=1) {
q.push(u);
res[u] = 1;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1492 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1860 KB |
Output is correct |
2 |
Correct |
6 ms |
1760 KB |
Output is correct |
3 |
Correct |
6 ms |
1856 KB |
Output is correct |
4 |
Correct |
21 ms |
1768 KB |
Output is correct |
5 |
Correct |
15 ms |
1760 KB |
Output is correct |
6 |
Correct |
8 ms |
1620 KB |
Output is correct |
7 |
Correct |
8 ms |
1632 KB |
Output is correct |
8 |
Correct |
7 ms |
1620 KB |
Output is correct |
9 |
Correct |
6 ms |
1620 KB |
Output is correct |
10 |
Correct |
7 ms |
1536 KB |
Output is correct |
11 |
Correct |
9 ms |
1572 KB |
Output is correct |
12 |
Correct |
7 ms |
1472 KB |
Output is correct |
13 |
Correct |
31 ms |
1872 KB |
Output is correct |
14 |
Incorrect |
31 ms |
1872 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
1492 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1828 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1492 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |