#include "train.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int INF = 1e9+10;
const ll LINF = 1e18+10;
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define mk make_pair
#define pb push_back
#define f first
#define s second
int t;
bool vis[5005], inv[5005];
vector<int> edges[5005];
bool dfs(int x, int raiz) {
if(inv[x]) return 0;
vis[x] = 1;
for(auto viz : edges[x]) {
if(viz == raiz) return 1;
if(vis[viz]) continue;
if(dfs(viz,raiz)) return 1;
}
return 0;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = sz(a), m = sz(u);
vector<int> res(n);
for(int i = 0; i < m; i++) edges[v[i]].pb(u[i]);
queue<int> fila;
for(int i = 0; i < n; i++)
if(r[i]) inv[i] = 1;
for(int i = 0; i < n; i++) {
if(!r[i]) {
memset(vis, 0, sizeof(vis));
if(dfs(i,i)) fila.push(i);
}
}
while(!fila.empty()) {
int x = fila.front();
fila.pop();
if(res[x]) continue;
res[x] = 1;
for(auto viz : edges[x])
fila.push(viz);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
860 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
110 ms |
1560 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1116 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
268 ms |
1484 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
860 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |