This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#include "grader.cpp"
#else
#include "train.h"
#endif
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
const int SIZE = 5005;
int n, m;
vector<int> adj[SIZE];
bool alice[SIZE], is[SIZE], self[SIZE], nxt[SIZE], dir[SIZE], ans[SIZE];
vector<int> who_wins(vector<int> a_, vector<int> r_, vector<int> u, vector<int> v) {
n = a_.size();
m = u.size();
FOR (i, 1, n) {
alice[i] = a_[i - 1];
is[i] = r_[i - 1];
adj[i].clear();
self[i] = nxt[i] = 0;
}
FOR (i, 0, m - 1) {
u[i]++, v[i]++;
if (u[i] == v[i]) self[u[i]] = 1;
else nxt[u[i]] = 1;
}
FOR (i, 1, n) {
if (alice[i]) {
if ((is[i] && self[i]) || nxt[i] == 0) dir[i] = 0;
else dir[i] = 1;
} else {
if ((is[i] == 0 && self[i]) || nxt[i] == 0) dir[i] = 0;
else dir[i] = 1;
}
}
for (int i = n; i >= 1; i--) {
if (dir[i] == 0) ans[i] = is[i];
else ans[i] = ans[i + 1];
}
vector<int> res;
FOR (i, 1, n) res.pb(ans[i]);
return res;
}
/*
in1
2 4
0 1
1 0
0 0
0 1
1 0
1 1
out1
1 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |