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 "gift.h"
#include <bits/stdc++.h>
using namespace std;
int construct(int N, int K, vector<int> A, vector<int> B, vector<int> C) {
vector<int> D(N);
for(int i = K; i--;) if(1 == C[i] && A[i] != B[i]) {
D[A[i]]++; D[B[i]]--;
}
for(int i = 1; i < N; i++) D[i] += D[i-1];
vector<int> E(N);
for(int i = 1, c = 0; i < N; i++) {
if(!D[i-1]) c ^= 1;
E[i] = c;
}
for(int i = N; i; i--) D[i] = 0;
for(int i = 1; i < N; i++) D[i-1] = E[i-1] ^ E[i];
for(int i = 1; i < N; i++) D[i] += D[i-1];
for(int i = K; i--;)
if(2 == C[i] && (A[i] == B[i] || D[B[i]-1] == (A[i] ? D[A[i]-1] : 0)))
return 0;
string ret;
for(int i = 0; i < N; i++) ret += E[i] ? 'R' : 'B';
craft(ret);
return 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... |