# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1243265 | YassirSalama | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 1 ms | 328 KiB |
#include <vector>
#include "messy.h"
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pb push_back
std::vector<int> restore_permutation(int n, int w, int r) {
auto f = [&](int i){
string s = string(n,'0');
for(int j = 0;j<=i;j++) s[j] = '1';
return s;
};
for(int i = 0;i<n;i++){
add_element(f(i));
// cout<<i<<" "<<f(i)<<endl;
}
compile_set();
vector<int> p(n);
for(int i = 0;i<n;i++){
for(int j = i+1;j<n;j++){
vector<int> p(n);
for(int k = 0;k<n;k++){
p[k] = k;
}
swap(p[i],p[j]);
//we have i<j
//we need the string to be 111101110
//take the string with index j-1
string t = f(j-1);
swap(t[i],t[j]);
// cout<<"! "<<i<<" "<<j<<" "<<t<<endl;
if(check_element(t)){
return p;
}
}
}
for(int i = 0;i<n;i++){
p[i] = i;
}
return p;
}
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... |