#include <bits/stdc++.h>
using namespace std;
using i32 = int;
using i64 = long long;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T>>;
template <typename T>
using VVV = V<V<V<T>>>;
#define OVERLOAD4(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, l, r) for (i32 i = (i32)(l); i < (i32)(r); ++i)
#define REP(...) OVERLOAD4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER2(i, n) for (i32 i = (i32)(n) - 1; i >= 0; --i)
#define PER3(i, l, r) for (i32 i = (i32)(r) - 1; i >= (i32)(l); --i)
#define PER(...) OVERLOAD4(__VA_ARGS__, PER3, PER2)(__VA_ARGS__)
#define ALL(x) begin(x), end(x)
#define LEN(x) (i32)size(x)
template <typename T>
bool chmin(T &x, const T &y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
if (x < y) {
x = y;
return true;
}
return false;
}
void dbg(i32 x) { cerr << x; }
void dbg(i64 x) { cerr << x; }
template <typename T>
void dbg(const V<T> &arr) {
cerr << "[";
REP(i, LEN(arr)) {
if (i) {
cerr << ", ";
}
dbg(arr[i]);
}
cerr << "]";
}
void debug() {}
template <typename Head, typename... Tail>
void debug(const Head &head, const Tail &... tail) {
dbg(head);
if (sizeof...(Tail)) {
cerr << ", ";
} else {
cerr << '\n';
}
debug(tail...);
}
#ifdef DEBUGF
#define DBG(...) do { cerr << #__VA_ARGS__ << " : "; debug(__VA_ARGS__); } while (false)
#else
#define DBG(...) (void)0
#endif
#include "train.h"
V<i32> who_wins(V<i32> a, V<i32> r, V<i32> u, V<i32> v) {
i32 n = LEN(a);
i32 m = LEN(u);
VV<i32> g(n), rg(n);
REP(i, m) {
g[u[i]].push_back(v[i]);
rg[v[i]].push_back(u[i]);
}
REP(i, m) {
assert(v[i] == u[i] || v[i] == u[i] + 1);
}
DBG(g);
V<i32> ans(n, 0);
PER(i, n) {
if (r[i] == 1) {
ans[i] = 1;
if (a[i] == 0) {
for (i32 j : g[i]) {
if (ans[j] == 0) {
ans[i] = 0;
}
}
}
} else {
ans[i] = 0;
if (a[i] == 1) {
for (i32 j : g[i]) {
if (ans[j] == 1) {
ans[i] = 1;
}
}
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1112 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 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
2904 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
2392 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2908 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1112 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |