#include "train.h"
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define N 5010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>
#define sz(a) int(a.size())
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
ll bigmod(ll a,ll e) {if(e==0)return 1;ll x=bigmod(a*a%mod,e>>1);return e&1?x*a%mod:x;}
int n, m;
int A[N];
int vis[N];
vector <int> E[N], T[N];
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v)
{
n = sz(a), m = sz(u);
for(int i = 0; i < m; i++) E[u[i]].pb(v[i]), T[v[i]].pb(u[i]);
queue <int> Q;
for(int i = 0; i < n; i++) {
if(r[i] == 0) continue;
int ok = 0;
for(auto h: E[i]) if(i == h) ok = 1;
if(ok == 1 && a[i] == 1) Q.push(i), vis[i] = 1;
}
while(!Q.empty()) {
int nd = Q.front();
Q.pop();
A[nd] = 1;
for(auto i: T[nd]) {
if(vis[i] == 1) continue;
int ok = 1;
if(a[i] == 0) for(auto j: E[i]) if(i == j) ok = 0;
vis[i] = 1;
if(ok == 1) Q.push(i);
}
}
vector <int> ret;
for(int i = 0; i < n; i++) ret.pb(A[i]);
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1152 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1536 KB |
Output is correct |
2 |
Correct |
9 ms |
1408 KB |
Output is correct |
3 |
Correct |
9 ms |
1408 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1408 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1280 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 |
10 ms |
1408 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 |
5 ms |
1152 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |