#include<bits/stdc++.h>
#include "train.h"
using namespace std;
#define pb push_back
int vis[5005]={0};
vector<int> answer;
vector<int> G[5005];
int charge[5005]={0};
int flag=0;
void dfs(int node){
vis[node]=1;
if(charge[node]) flag=1;
for(int i:G[node]){
if(!vis[i]) dfs(i);
}
}
vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v){
for(int i=0;i<(int)r.size();i++){
charge[i]=r[i];
}
for(int i=0;i<(int)u.size();i++){
G[u[i]].push_back(v[i]);
}
for(int i=0;i<(int)a.size();i++){
flag=0;
for(int j=0;j<(int)a.size();j++){
vis[j]=0;
}
dfs(i);
if(flag) answer.pb(1);
else answer.pb(0);
}
for(int i=0;i<2*(int)a.size();i++){
//cout<<"ok";
for(int j=0;j<(int)a.size();j++){
int flag2=0;
for(int k:G[j]){
if(answer[k]!=0) flag2=1;
}
if(!flag2) answer[j]=0;
}
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
303 ms |
972 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
404 ms |
1368 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
993 ms |
1040 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1270 ms |
1248 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
303 ms |
972 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |