#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(x==poc){
return 1;
}
if(bio[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]=1;
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, 0);
for(int i=0; i<n; i++){
if(charge[i]){
if(dfs(i)){
nazad(i);
}
memset(bio, 0, sizeof(bio));
}
}
bool p=1;
while(p){
p=0;
for(int i=0; i<n; i++){
if(sol[i]){
continue;
}
for(int j=0; j<(int)ms[i].size(); j++){
if(sol[ms[i][j]]){
sol[i]=1;
p=1;
break;
}
}
}
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
144 ms |
1228 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
1868 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
838 ms |
1444 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
1612 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
144 ms |
1228 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |