# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1156743 | Doncho_Bonboncho | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
#include <cstring>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#include "messy.h"
using namespace std;
#ifndef LOCAL
#define cerr if( false ) cerr
#endif
#define out(x) #x << " = " << x << " "
std::vector<int> restore_permutation(int n, int w, int r) {
for( int i=0 ; i < n-1 ; i++ ){
std::string curr = "";
for( int j=0 ; j < n ; j++ ){
if( j <= i ) curr += "1";
else curr += "0";
}
cerr << out(curr ) << endl;
add_element( curr );
}
compile_set();
std::vector< int > unKnown( n );
std::iota( unKnown.begin(), unKnown.end(), 0 );
std::string base = "";
std::vector< int > nas( n );
for( int i=0 ; i < n ; i++ ) base += "0";
for( int i=0 ; i < n -1 ; i++ ){
for( int j=0 ; j < (int)unKnown.size() ; j++ ){
std::string curr = base;
curr[unKnown[j]] = '1';
cerr << " ? " << out( curr ) << endl;
if( check_element( curr ) ){
//nas[i] = unKnown[j];
nas[ unKnown[j] ] = i;
base = curr;
std::swap( unKnown[j], unKnown.back() );
unKnown.pop_back();
break;
}
}
}
//nas[n-1] = unKnown[0];
nas[unKnown[0]] = n-1;
/*
std::cout << n << " " << w << " " << r << endl;
for( auto j : nas ) std::cout << j << " ";
std::cout << endl;
*/
return nas;
}
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... |