# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747752 | LIF | Handcrafted Gift (IOI20_gift) | C++14 | 180 ms | 20768 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>
#include<string>
#include<vector>
using namespace std;
int ass[500005];
vector<pair<int,int> > one;
//first step : assort it , such that 1111 , 2222;
int construct(int n, int r, vector<int> a, vector<int> b, std::vector<int> x) {
int pos = 1;
for(int i=0;i<r;i++)
{
if(x[i] == 1)one.push_back(make_pair(a[i],b[i]));
if(x[i] == 2 && b[i] == a[i])return 0;
}
sort(one.begin(),one.end());
int poss = 1;
int last = 0;
for(int i=0;i<one.size();i++)
{
int mxr = one[i].second;
while(one[i].first <= mxr && i<= one.size()-1)
{
mxr = max(mxr,one[i].second);
i++;
}
i--;
for(int j=last;j<=mxr;j++)ass[j] = poss;
last = mxr + 1;
poss++;
}
for(int i=0;i<r;i++)
{
if(x[i] == 1)continue;
if(ass[b[i]] == ass[a[i]] && ass[b[i]] != 0)return 0;
}
string s;
s += "R";
int lastmax = -1;
if(ass[0] == 1) lastmax = 1;
for(int i=1;i<n;i++)
{
if(ass[i] == 0)
{
if(s[i-1] == 'R')s += "B";
else s += "R";
continue;
}
if(ass[i] == lastmax)
{
s += s[i-1];
continue;
}
if(ass[i] > lastmax)
{
lastmax = ass[i];
if(s[i-1] == 'R')s += "B";
else s += "R";
continue;
}
}
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... |