#ifdef NYAOWO
#include "grader.cpp"
#endif
#include "train.h"
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;
const int MAXN = 5000;
vector<int> adj[MAXN + 10];
vector<int> rev[MAXN + 10];
int tag[MAXN + 10];
void walk(int s, vector<int> ad[], int tg) {
queue<int> que;
que.emplace(s);
tag[s] |= tg;
while(!que.empty()) {
int cur = que.front(); que.pop();
for(auto &i:ad[cur]) if((tag[i] & tg) == 0) {
tag[i] |= tg;
que.emplace(i);
}
}
}
vector<i32> who_wins(vector<i32> a, vector<i32> r, vector<i32> u, vector<i32> v) {
int n = sz(a);
int m = sz(u);
For(i, 0, m - 1) {
adj[u[i]].eb(v[i]);
rev[v[i]].eb(u[i]);
}
memset(tag, 0, sizeof(tag));
int s = -1;
For(i, 0, n - 1) if(r[i]) s = i;
walk(s, adj, 1);
walk(s, rev, 2);
vector<i32> mangocube(n);
For(i, 0, n - 1) mangocube[i] = (tag[i] == 3);
return mangocube; // mango & cube win
}
/*
2 4
0 1
1 0
0 0
0 1
1 0
1 1
1 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
980 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
468 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1620 KB |
3rd lines differ - on the 4994th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1304 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 |
7 ms |
1620 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 |
980 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |