| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 355373 | dolphingarlic | Handcrafted Gift (IOI20_gift) | C++14 | 237 ms | 24916 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 <bits/stdc++.h>
using namespace std;
int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) {
    vector<pair<int, int>> sing, doub, itv;
    for (int i = 0; i < r; i++) {
        if (x[i] == 1) sing.push_back({a[i], b[i]});
        else doub.push_back({a[i], b[i]});
    }
    sort(sing.begin(), sing.end());
    pair<int, int> curr = {-1, -1};
    for (pair<int, int> i : sing) {
        if (i.first > curr.second) {
            itv.push_back(curr);
            curr = i;
        } else curr.second = max(curr.second, i.second);
    }
    itv.push_back(curr);
    sort(doub.begin(), doub.end());
    int s_ptr = 1;
    for (pair<int, int> i : doub) {
        while (s_ptr < itv.size() - 1 && itv[s_ptr].second < i.first)
            s_ptr++;
        if (i.first == i.second || (i.first >= itv[s_ptr].first && i.second <= itv[s_ptr].second))
            return 0;
    }
    string ret(n, '.');
    char c = 'R';
    for (int i = 1; i < itv.size(); i++) {
        for (int j = itv[i - 1].second + 1; j < itv[i].first; j++) {
            ret[j] = c;
            c = 'R' + 'B' - c;
        }
        for (int j = itv[i].first; j <= itv[i].second; j++)
            ret[j] = c;
        c = 'R' + 'B' - c;
    }
    for (int j = itv.back().second + 1; j < n; j++) {
        ret[j] = c;
        c = 'R' + 'B' - c;
    }
    craft(ret);
    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... | ||||
