# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306838 | joylintp | Handcrafted Gift (IOI20_gift) | C++14 | 262 ms | 16992 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>> v;
for (int i = 0; i < r; i++)
if (x[i] == 1)
v.push_back({a[i], b[i]});
sort(v.begin(), v.end());
vector<pair<int, int>> same;
for (int i = 0; i < v.size(); i++)
if (same.empty())
same.push_back(v[i]);
else if (same.back().second >= v[i].first)
same.back().second = max(same.back().second, v[i].second);
else
same.push_back(v[i]);
string s(n, '_');
for (auto p : same)
for (int i = p.first; i <= p.second; i++)
s[i] = 'R';
for (int i = 0; i < n; )
if (s[i] == '_')
{
int j = i;
while (j < n && s[j] == '_')
s[j] = "BR"[(j - i) % 2], j++;
i = j;
}
else
i++;
vector<int> v2;
for (auto p : same)
v2.push_back(p.first), v2.push_back(p.second);
for (int i = 0; i < r; i++)
{
if (x[i] == 1)
continue;
if (a[i] == b[i])
return 0;
int pos = lower_bound(v2.begin(), v2.end(), a[i]) - v2.begin();
if (pos < v2.size() && pos % 2 == 0 && b[i] <= v2[pos + 1])
return 0;
}
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... |