# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
651388 | Alan | Handcrafted Gift (IOI20_gift) | C++17 | 0 ms | 0 KiB |
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 b = true;
for (int i = 0; i < n; i++) {
if (!d[i]) b = !b;
s[i] = b ? '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]] : 0);
if (diff == 0 || diff == b[i]-a[i]+1) return 0;
}
craft(s);
return 1;
}