#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 t0[MAXN + 10];
int t1[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]);
if(u[i] == v[i]) t0[u[i]] = 1;
else t1[u[i]] = 1;
}
memset(tag, 0, sizeof(tag));
vector<i32> owo(n);
Forr(i, n - 1, 0) {
if(a[i]) {
if(r[i] && t0[i]) owo[i] = 1;
else if(!t1[i]) owo[i] = 0;
else owo[i] = owo[i + 1];
} else {
if(!r[i] && t0[i]) owo[i] = 0;
else if(!t1[i]) owo[i] = 1;
else owo[i] = owo[i + 1];
}
}
return owo;
}
/*
2 4
0 1
1 0
0 0
0 1
1 0
1 1
1 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1108 KB |
Output is correct |
2 |
Correct |
3 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1192 KB |
Output is correct |
4 |
Correct |
3 ms |
1236 KB |
Output is correct |
5 |
Correct |
4 ms |
1340 KB |
Output is correct |
6 |
Correct |
3 ms |
1236 KB |
Output is correct |
7 |
Correct |
3 ms |
1224 KB |
Output is correct |
8 |
Correct |
3 ms |
1228 KB |
Output is correct |
9 |
Correct |
3 ms |
1192 KB |
Output is correct |
10 |
Correct |
3 ms |
1124 KB |
Output is correct |
11 |
Correct |
3 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 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 |
5 ms |
1620 KB |
Output is correct |
2 |
Correct |
6 ms |
1620 KB |
Output is correct |
3 |
Correct |
5 ms |
1548 KB |
Output is correct |
4 |
Incorrect |
6 ms |
1688 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 |
5 ms |
1364 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 |
6 ms |
1620 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 |
Correct |
3 ms |
1108 KB |
Output is correct |
2 |
Correct |
3 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1192 KB |
Output is correct |
4 |
Correct |
3 ms |
1236 KB |
Output is correct |
5 |
Correct |
4 ms |
1340 KB |
Output is correct |
6 |
Correct |
3 ms |
1236 KB |
Output is correct |
7 |
Correct |
3 ms |
1224 KB |
Output is correct |
8 |
Correct |
3 ms |
1228 KB |
Output is correct |
9 |
Correct |
3 ms |
1192 KB |
Output is correct |
10 |
Correct |
3 ms |
1124 KB |
Output is correct |
11 |
Correct |
3 ms |
1108 KB |
Output is correct |
12 |
Incorrect |
1 ms |
468 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |