# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
569053 | losmi247 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 0 ms | 0 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;
typedef long long ll;
int n,w,r;
bool check_element(string x){
for(auto f : nv){
if(f == x) return 1;
}
return 0;
}
vector <int> prvi(){
add_element("11110000");
add_element("11000000");
add_element("00000011");
add_element("10000000");
add_element("00100000");
add_element("00001000");
add_element("00000010");
compile_set();
vector <int> ret(8,0);
for(int i = 0; i < 8; i++) ret[i] = i;
string s = "11110000";
for(int i = 0; i < 4; i++){
for(int j = 4; j < 8; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
s = "11000000";
for(int i = 0; i < 2; i++){
for(int j = 2; j < 4; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
s = "00000011";
for(int i = 4; i < 6; i++){
for(int j = 6; j < 7; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
//cout << "najmanji" << endl;
s = "10000000";
for(int i = 0; i < 1; i++){
for(int j = 1; j < 2; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
s = "00100000";
for(int i = 2; i < 3; i++){
for(int j = 3; j < 4; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
s = "00001000";
for(int i = 4; i < 5; i++){
for(int j = 5; j < 6; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
s = "00000010";
for(int i = 6; i < 7; i++){
for(int j = 7; j < 8; j++){
string h = s;
swap(h[i],h[j]);
if(check_element(h)){
swap(ret[i],ret[j]);
return ret;
}
}
}
return ret;
}
vector <int> restore_permutation(int N,int W,int R){
n = N;
w = W;
r = R;
if(n == 8 && w == 256 && r == 256){
return prvi();
}
}