# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1020929 | TheWilp | Handcrafted Gift (IOI20_gift) | C++14 | 1567 ms | 29688 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 "gift.h"
#include <algorithm>
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
std::string s;
std::vector<std::pair<int,int>> r1,r2;
for(int q = 0;q < r;q++) {
if(x[q] == 1) {
r1.push_back({a[q],b[q]});
}
else {
r2.push_back({a[q],b[q]});
}
}
std::sort(r1.begin(),r1.end());
std::vector<int> v(n);
std::vector<int> t;
int place = 0;
int i = 0;
for(int q = 0;q < n;q++) {
while (i < r1.size() && r1[i].first == q) {
t.push_back(r1[i].second);
++i;
}
while(t.size() && t.back() <= q) t.pop_back();
v[q] = place;
if(t.size() == 0)
place++;
}
bool is_yes = true;
for(int q = 0;q < r2.size();q++){
if(v[r2[q].first] == v[r2[q].second]) {
is_yes = false;
break;
}
}
if(!is_yes) {
return 0;
}
else {
for(int q = 0;q < n;q++) {
if(v[q] % 2) {
s = s + 'R';
}
else {
s = s + 'B';
}
}
craft(s);
return 1;
}
}
Compilation message (stderr)
# | 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... |