This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
bitset < N > win[2][2 * N];
int n , m;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
n = a.size();
m = u.size();
vector<int> res;
for(int i=0;i<n;i++) win[0][0][i] = r[i];
for(int i=1;i<=n;i++){
for(int j=0;j<n;j++) win[0][i][j] = (r[j] == 1 ? 1 : (a[j] ^ 1));
for(int j=0;j<m;j++){
if(r[u[j]]) continue;
if(a[u[j]]){
if(win[0][i-1][v[j]] == 1) win[0][i][u[j]] = 1;
}
else{
if(win[0][i-1][v[j]] == 0) win[0][i][u[j]] = 0;
}
}
}
for(int i=0;i<n;i++) win[1][0][i] = win[0][n][i];
for(int i=1;i<=m;i++){
for(int j=0;j<n;j++) win[1][i][j] = (win[0][n][j] == 0 ? 0 : a[j] ^ 1);
for(int j=0;j<m;j++){
if(a[u[j]]){
if(win[1][i-1][v[j]] == 1) win[1][i][u[j]] = 1;
}
else{
if(win[1][i-1][v[j]] == 0) win[1][i][u[j]] = 0;
}
}
}
for(int i=0;i<n;i++) res.push_back(win[1][m][i]);
return res;
}
# | 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... |