# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
412850 | MasterTaster | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 1 ms | 296 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"
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
using namespace std;
vector<int> p;
int xNady(int x, int y)
{
if (y==0) return 1;
int ret=1;
for (int i=x; i>x-y; i--) ret*=i;
for (int i=y; i>0; i--) ret/=i;
return ret;
}
std::vector<int> restore_permutation(int n, int w, int r) {
if (n==8)
{
for (int i=0; i<7; i++)
{
for (int mask=0; mask<(1<<8); mask++)
{
if (__builtin_popcount(mask)!=i+1) continue;
if (mask&(1<<i)) continue;
string s="00000000";
for (int j=0; j<8; j++) if (mask&(1<<j)) s[j]='1'; else s[j]='0';
add_element(s);
///cout<<"dodajem "<<s<<endl;
}
}
///cout<<endl<<"kad obrnes:"<<endl;
compile_set();
///cout<<endl;
int kolko[10];
for (int i=0; i<7; i++)
{
for (int j=0; j<8; j++) kolko[j]=0;
for (int mask=0; mask<(1<<8); mask++)
{
if (__builtin_popcount(mask)!=i+1) continue;
string s="00000000";
for (int j=0; j<8; j++) if (mask&(1<<j)) s[j]='1'; else s[j]='0';
bool dal=check_element(s);
if (!dal) continue;
///cout<<s<<endl;
for (int j=0; j<8; j++) if (mask&(1<<j)) kolko[j]++;
if (mask&(1<<i))
{
int drugi=-1;
mask++;
for (; mask<(1<<8); mask++)
{
if (__builtin_popcount(mask)!=i+1) continue;
string s="00000000";
for (int j=0; j<8; j++) if (mask&(1<<j)) s[j]='1'; else s[j]='0';
bool dal=check_element(s);
if (!dal) continue;
for (int j=0; j<8; j++) if (mask&(1<<j)) kolko[j]++;
}
for (int j=0; j<8; j++)
{
if (j==i) continue;
///cout<<j<<" j kolko[j] "<<kolko[j]<<endl;
if (kolko[j]!=xNady(6, i)) { drugi=j; break; }
}
//cout<<i<<" "<<drugi<<endl;
for (int j=0; j<8; j++)
{
if (j!=i && j!=drugi) p.pb(j);
else if (j==i) p.pb(drugi);
else p.pb(i);
}
return p;
}
}
}
for (int i=0; i<8; i++) p.pb(i);
return p;
}
/*add_element("0");
compile_set();
check_element("0");
return std::vector<int>();*/
}
/*
8 256 256
0 1 2 6 4 5 3 7
*/
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... |