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, vector<int> a, vector<int> b, vector<int> x) {
int painting[n + 1] = {0};
for (int i = 0; i < r; i ++) {
if (x[i] == 1) {
painting[b[i] + 1] --;
painting[a[i]] ++;
}
}
for (int i = 1; i < n; i ++) {
painting[i] += painting[i - 1];
}
int encrypt[n + 1] = {0};
int ind = 0, color = 0;
string s(n, 'R');
while (ind < n) {
if (painting[ind] == 0) {
encrypt[ind] = color;
ind ++;
}
else {
while ((ind < n) and (painting[ind] >= 1)) {
encrypt[ind] = color;
ind ++;
}
}
color = (color + 1) % 2;
}
for (int i = 0; i < n; i ++) {
if (encrypt[i] == 0) s[i] = 'R';
else s[i] = 'B';
}
int pref[n + 1] = {0};
for (int i = 1; i <= n; i ++) {
pref[i] = encrypt[i] + pref[i - 1];
}
for (int i = 0; i < r; i ++) {
int cible = pref[b[i]] - pref[a[i] - 1];
int longueur = b[i] - a[i] + 1;
if (x[i] == 2) {
if ((0 < cible) and (cible < longueur)) ;
else {
return 0;
}
}
else {
if ((0 < cible) and (cible < longueur)) return 0;
else ;
}
}
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... |