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 m, vector<int> a, vector<int> b, vector<int> x) {
string s (n, 0);
vector<int> d (n+1), ps (n+1);
for (int i = 0; i < m; i++) if (x[i] == 1) {
d[a[i]]++;
d[b[i]+1]--;
}
bool r = true;
for (int i = 0; i < n; i++) {
if (i) d[i] += d[i-1];
if (!d[i] || (i && !d[i-1])) r = !r;
s[i] = r ? 'R' : 'B';
ps[i] += s[i] == 'B';
if (i) ps[i] += ps[i-1];
}
for (int i = 0; i < m; i++) if (x[i] == 2) {
int diff = ps[b[i]] - (a[i] ? ps[a[i]-1] : 0);
if (diff == 0 || diff == b[i]-a[i]+1) 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... |