# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
967603 | MarwenElarbi | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 2 ms | 604 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<bits/stdc++.h>
using namespace std;
void add_element(std::string x);
bool check_element(std::string x);
void compile_set();
string text;
set<int> st;
void dav_add(int l,int r){
int mid=(r+l)/2;
if(l==r) return;
for (int i = l; i <= mid; ++i)
{
text[i]='1';
//cout <<text<<endl;
add_element(text);
text[i]='0';
}
for (int i = mid+1; i <= r ; ++i)
{
text[i]='1';
}
dav_add(l,mid);
for (int i = mid+1; i <= r ; ++i)
{
text[i]='0';
}
for (int i = l; i <= mid; ++i)
{
text[i]='1';
}
dav_add(mid+1,r);
for (int i = l; i <= mid; ++i)
{
text[i]='0';
}
return;
}
vector<int> res;
void dav_check(int l,int r){
vector<int> left;
vector<int> right;
if(l==r){
res[*st.begin()]=l;
return;
}
for(auto u:st){
text[u]='1';
//cout <<u<<" ";
if(!check_element(text)){
right.push_back(u);
}else {
left.push_back(u);
//cout <<text<<endl;
}
text[u]='0';
}//cout <<endl;
for (int i = 0; i < right.size(); ++i)
{
//cout <<right[i]<<" ";
text[right[i]]='1';
st.erase(right[i]);
}//cout <<endl;
int mid=(r+l)/2;
dav_check(l,mid);
for (int i = 0; i < right.size(); ++i)
{
text[right[i]]='0';
st.insert(right[i]);
}
for (int i = 0; i < left.size(); ++i)
{
text[left[i]]='1';
st.erase(left[i]);
}
dav_check(mid+1,r);
for (int i = 0; i < left.size(); ++i)
{
text[left[i]]='0';
st.insert(left[i]);
}
return;
}
std::vector<int> restore_permutation(int n, int w, int r) {
text="";
res.resize(n);
for (int i = 0; i < n; ++i)
{
st.insert(i);
text.push_back('0');
}
dav_add(0,n-1);
compile_set();
dav_check(0,n-1);
return res;
}
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... |