# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121348 | Charis02 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 4 ms | 384 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 <vector>
#include <algorithm>
#include "messy.h"
#define rep(i,a,b) for(int i = a;i < b;i++)
using namespace std;
vector < int > result(230);
void init(int low,int high,int n)
{
if(low == high)
return;
int mid = (low+high)/2;
string s = "";
rep(i,0,n)
s += "1";
rep(i,low,high+1)
s[i] = '0';
rep(i,low,mid+1)
{
s[i] = '1';
add_element(s);
s[i] = '0';
}
init(low,mid,n);
init(mid+1,high,n);
return;
}
void solve(int low,int high,int n,vector < int > pos,string s)
{
if(low == high)
{
result[low] = pos[0];
return;
}
int mid = (low+high)/2;
string aristera = s;
string deksia = s;
vector < int > posl;
vector < int > posr;
rep(i,0,n)
{
aristera[i] = deksia[i] = '1';
}
rep(i,0,pos.size())
{
aristera[pos[i]] = deksia[pos[i]] = '0';
}
rep(i,0,pos.size())
{
int x = pos[i];
s[x] = '1';
if(check_element(s))
{
aristera[x] = '1';
posl.push_back(x);
}
else
{
deksia[x] = '1';
posr.push_back(x);
}
}
solve(low,mid,n,posl,aristera);
solve(mid+1,high,n,posr,deksia);
return;
}
std::vector<int> restore_permutation(int n, int w, int r) {
string s = "";
init(0,n-1,0);
compile_set();
vector < int > v;
rep(i,0,n)
{
v.push_back(i);
s += "0";
}
solve(0,n-1,n,v,s);
}
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... |