# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966949 | MarwenElarbi | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 1 ms | 436 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;
void add_element(std::string x);
bool check_element(std::string x);
void compile_set();
std::vector<int> restore_permutation(int n, int w, int r){
vector<int> res(n);
string cur;
set<int> st;
int a=1;
for (int i = 0; i < 8; ++i)
{
res[i]=i;
st.insert(a);
a*=2;
}
for (int i = 0; i < n; ++i)
{
cur.push_back('0');
}
for (int i = 0; i < n; ++i)
{
cur[i]='1';
add_element(cur);
}
compile_set();
int ok[(1<<n)];
vector<int> compare[n+1];
//cout <<"nabba"<<endl;
for (int i = 0; i < (1<<n); ++i)
{
string ne="";
for (int j = 0; j < n; ++j)
{
if(i&(1<<j)) ne.push_back('1');
else ne.push_back('0');
}
//cout <<compiled<<" "<<ne<<endl;
compare[__builtin_popcount(i)].push_back(i);
ok[i]=check_element(ne);
//cout <<ne<<" "<<i<<" "<<ok[i]<<endl;
}
//cout <<ok[2]<<endl;
for (int i = 1; i <= n; ++i)
{
//cout <<i<<" "<<compare[i].size()<<endl;
for (int j = 0; j < compare[i].size(); ++j)
{
//cout <<compare[i][j]<<endl;
if(ok[compare[i][j]]==0||st.count(compare[i][j])) continue;
else {
//cout <<"hey"<<" "<<i<<" "<<compare[i][j]<<endl;
for (int k = i; k < n; ++k)
{
if((1<<k)&compare[i][j]){
//cout <<i-1<<" "<<k<<endl;
res[i-1]=k;
res[k]=i-1;
return res;
}
}
}
}
}
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... |