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> maxR(n, 0), cnt(n, 0);
for(int i = 0; i < r; i++){
if (x[i] == 2)
continue;
maxR[a[i]] = max(maxR[a[i]], b[i]);
}
for(int i = 0; i < n; i++){
maxR[i] = max(maxR[i], i);
if (i > 0)
maxR[i] = max(maxR[i], maxR[i - 1]);
if (maxR[i] == i){
cnt[i]++;
}
if (i > 0)
cnt[i] += cnt[i - 1];
}
for(int i = 0; i < r; i++){
if (x[i] == 1)
continue;
if (a[i] == b[i])
return 0;
int tmp = cnt[b[i] - 1];
if (a[i] > 0)
tmp -= cnt[a[i] - 1];
if (tmp < 1)
return 0;
}
string res;
for(int i = 0; i < n; i++)
res.push_back((cnt[i] & 1)? 'R' : 'B');
craft(res);
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... |