# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430032 | schse | Handcrafted Gift (IOI20_gift) | C++17 | 334 ms | 29944 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;
#ifndef EVAL
#include "grader.cpp"
#endif
struct requirement
{
int a, b, x;
bool operator<(const requirement &other)
{
return a != other.a ? a < other.a : b < other.b;
}
};
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x)
{
set<pair<int, int>> s;
vector<requirement> re;
for (int i = 0; i < a.size(); i++)
re.push_back({a[i], b[i], x[i]});
sort(re.rbegin(), re.rend());
for (auto i : re) //update single color
{
if (i.x == 1)
{
auto it = s.lower_bound(make_pair(i.a, i.b));
while (it != s.end())
{
if (it->first > i.b)
break;
i.b = max(i.b, it->second);
s.erase(it);
it = s.lower_bound({i.a, i.b});
}
s.insert({i.a, i.b});
s = s;
}
}
vector<int> prefarr;
for (int v = 0, i = 0; i < n; i++)
{
while (s.size() && s.begin()->second < i)
s.erase(s.begin());
if (!s.size() || s.begin()->first >= i)
v++;
prefarr.push_back(v);
}
for (auto i : re) //update single color
{
if (i.x == 2)
{
if (prefarr[i.a] == prefarr[i.b])
return 0;
}
}
std::string sr(n, 'R');
for (int i = 0; i < n; i++)
{
sr[i] = prefarr[i] % 2 ? 'R' : 'B';
}
craft(sr);
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... |