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 <bits/stdc++.h>
#include "gift.h"
using namespace std;
int construct(int n, int r, vector<int>a, vector<int>b, vector<int>x) {
vector<int>one(n+1, 0), start(n, 0);
for(int i = 0 ; i < r ; i++) {
if(x[i] == 1)
one[a[i]]++, one[b[i]+1]--, start[a[i]]++;
}
int cnt = 0;
char C = 'R';
auto c = [&] (char X) -> char {
if(X == 'R')
return 'B';
return 'R';
};
string s = "";
vector<int>change(n+1,0);
for(int i = 0 ; i < n ; i++) {
cnt += one[i];
change[i+1] = change[i];
if(!cnt || start[i] == cnt) {
change[i+1]++;
C = c(C);
}
s += C;
}
bool ok = 1;
for(int i = 0 ; i < r ; i++) {
if(x[i] == 1) {
if(change[b[i]+1] - change[a[i]+1] != 0)
ok = 0;
} else {
if(change[b[i]+1] - change[a[i]+1] == 0)
ok = 0;
}
}
if(!ok)
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... |