#include <bits/stdc++.h>
#include "train.h"
#define N 20009
#define pii pair <int, int>
#define ff first
#define ss second
#define sz() size()
#define pb push_back
#define ll long long
using namespace std;
bool a[N];
vector<int>ans;
int asd=0;
int vis[N], c[N];
map<int, int>M[N];
void dfs(int nd){
vis[nd]=1;
if(a[nd]){
asd=1;
return;
}
if(M[nd][nd+1] and !vis[nd+1])
dfs(nd+1);
a[nd]=asd;
}
std::vector<int> who_wins(std::vector<int>o, std::vector<int>p, std::vector<int>u, std::vector<int>v){
int n=o.sz();
int m=u.sz();
for(int i=0; i<m; i++){
M[u[i]][v[i]]=1;
if(u[i]==v[i])
c[u[i]]=1;
}
for(int i=0; i<n; i++)
if(p[i]==1 and o[i]==1 and c[i]==1)
a[i]=1;
for(int i=0; i<n; i--){
if(!a[i] and !vis[i])
asd=0, dfs(i);
ans.pb(a[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
3584 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2408 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
5248 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
4608 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
14 ms |
5240 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
3584 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |