#include<bits/stdc++.h>
#include "train.h"
using namespace std;
#define pb push_back
int vis[5005]={0};
int rev_answer[5005]={0};
vector<int> answer;
vector<int> G[5005];
vector<int> rev_G[5005];
int charge[5005]={0};
int flag=-1;
void dfs(int node){
//cout<<"dfs node: "<<node;
vis[node]=1;
for(int i:G[node]){
if(!vis[i] && !charge[i]) dfs(i);
if(vis[i]) flag=i;
}
}
void rev_dfs(int node){
//cout<<"rev_dfs node: "<<node;
vis[node]=1;
for(int i:rev_G[node]){
if(!vis[i]){
rev_answer[i]=1;
rev_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]);
rev_G[v[i]].push_back(u[i]);
}
for(int i=0;i<(int)a.size();i++){
flag=-1;
for(int j=0;j<(int)a.size();j++){
vis[j]=0;
}
if(!charge[i]) dfs(i);
for(int j=0;j<(int)a.size();j++){
vis[j]=0;
}
if(flag!=-1) rev_dfs(flag);
}
for(int i=0;i<(int)a.size();i++){
if(!rev_answer[i]) answer.pb(1);
else answer.pb(0);
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
68 ms |
1140 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
284 ms |
1672 KB |
3rd lines differ - on the 1663rd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
1236 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1898 ms |
1656 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
68 ms |
1140 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |