# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66880 | MKopchev | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 4 ms | 640 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>
#include "messy.h"
using namespace std;
/*
set<string> q;
void add_element(string s)
{
cout<<"add "<<s<<endl;
q.insert(s);
}
void compile_set()
{
}
bool check_element(string s)
{
cout<<"ask "<<s<<endl;
if(q.count(s))return 1;
return 0;
}
*/
bool check(string s)
{
bool ret=check_element(s);
return ret;
}
vector<int> restore_permutation(int n, int w, int r)
{
srand(time(0));
string s={};
for(int i=0;i<n;i++)s=s+"1";
for(int i=0;i<n;i++)
{
s[i]='0';
add_element(s);
}
compile_set();
vector<int> result={};
for(int i=0;i<n;i++)result.push_back(-1);
for(int i=0;i<n;i++)
{
string s="";
for(int j=0;j<n;j++)s=s+"1";
for(int j=0;j<n;j++)
if(result[j]!=-1)s[j]='0';
vector<int> active={};
for(int j=0;j<n;j++)
if(s[j]=='1')active.push_back(j);
random_shuffle(active.begin(),active.end());
for(auto j:active)
{
s[j]='0';
r--;
assert(r>=0);
if(check(s))
{
result[j]=i;
break;
}
s[j]='1';
}
}
return result;
}
/*
int main()
{
for(auto k:restore_permutation(4,16,16))cout<<k<<endl;
}
*/
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... |