#include "train.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int maxn=5005;
int n, m;
vector < int > ms[maxn];
vector < int > rev[maxn];
int charge[maxn];
int tko[maxn];
bool bio[maxn];
vector < int > sol;
int poc;
int dfs(int x){
if(bio[x] && x==poc){
return 1;
}
if(bio[x] || charge[x]){
return 0;
}
bio[x]=1;
for(int i=0; i<(int)ms[x].size(); i++){
if(dfs(ms[x][i])){
return 1;
}
}
return 0;
}
void nazad(int x){
if(!sol[x]){
return;
}
sol[x]=0;
for(int i=0; i<(int)rev[x].size(); i++){
nazad(rev[x][i]);
}
}
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<n; i++){
tko[i]=a[i];
charge[i]=r[i];
}
for(int i=0; i<m; i++){
ms[u[i]].push_back(v[i]);
rev[v[i]].push_back(u[i]);
}
sol.resize(n, 1);
for(int i=0; i<n; i++){
if(!charge[i]){
poc=i;
if(dfs(i)){
nazad(i);
}
memset(bio, 0, sizeof(bio));
}
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1100 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
1640 KB |
Output is correct |
2 |
Correct |
38 ms |
1572 KB |
Output is correct |
3 |
Correct |
15 ms |
1484 KB |
Output is correct |
4 |
Incorrect |
401 ms |
1604 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1228 KB |
Output is correct |
2 |
Correct |
128 ms |
1400 KB |
Output is correct |
3 |
Correct |
214 ms |
1608 KB |
Output is correct |
4 |
Correct |
46 ms |
1604 KB |
Output is correct |
5 |
Correct |
390 ms |
1624 KB |
Output is correct |
6 |
Correct |
319 ms |
1580 KB |
Output is correct |
7 |
Correct |
312 ms |
1484 KB |
Output is correct |
8 |
Correct |
149 ms |
1532 KB |
Output is correct |
9 |
Correct |
11 ms |
1484 KB |
Output is correct |
10 |
Correct |
10 ms |
1612 KB |
Output is correct |
11 |
Correct |
10 ms |
1576 KB |
Output is correct |
12 |
Correct |
10 ms |
1612 KB |
Output is correct |
13 |
Correct |
342 ms |
1660 KB |
Output is correct |
14 |
Correct |
265 ms |
1520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
527 ms |
1484 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1100 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |