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 r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
std::string s(n, 'R');
vector<int> p(n, 0);
for(int i = 0; i < r; ++i) {
if(x[i] == 1) {
if(a[i] != b[i]) {
p[a[i] + 1]++;
if(b[i] + 1 < n) p[b[i] + 1]--;
}
}
}
for(int i = 0; i < n; ++i) {
if(i) p[i] += p[i - 1];
if(p[i]) s[i] = s[i - 1];
else if(s[i - 1] == 'B') s[i] = 'R';
else s[i] = 'B';
}
set<int> posR, posB;
posR.insert(n);
posB.insert(n);
for(int i = 0; i < n; ++i) {
if(s[i] == 'R') posR.insert(i);
else posB.insert(i);
}
for(int i = 0; i < r; ++i) {
auto A = *posR.lower_bound(a[i]);
auto B = *posB.lower_bound(a[i]);
int cnt = 0;
if(A <= b[i]) ++cnt;
if(B <= b[i]) ++cnt;
if(cnt != x[i]) return 0;
}
craft(s);
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... |