#include <algorithm>
#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) {
std::vector< int > ind( n );
std::iota( ind.begin(), ind.end(), 0 );
mt19937 gen( 1337 );
std::shuffle( ind.begin(), ind.end(), gen );
cerr << " ind : " << endl;
for( int i=0 ; i < n ; i++ ) cerr << ind[i] << " ";
cerr << endl << endl;
for( int i=0 ; i < n-1 ; i++ ){
std::string curr = "";
for( int j=0 ; j < n ; j++ ) curr += "0";
for( int j=0 ; j <= i ; j++ ){
curr[ ind[j] ] = '1';
}
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] ] = ind[i];
//nas[ unKnown[j] ] = ind[ ind[i] ];
cerr << out( i ) << out( ind[i] ) << out( unKnown[j] ) << endl;
base = curr;
std::swap( unKnown[j], unKnown.back() );
unKnown.pop_back();
break;
}
}
for( auto j : unKnown) cerr << j << " " ;
cerr << endl << endl;
}
//nas[n-1] = unKnown[0];
nas[ unKnown[0] ] = ind[n-1];
cerr << out( unKnown[0] ) << out( ind[n-1] ) << endl;
//std::cout << n << " " << w << " " << r << endl;
/*
for( auto j : nas ) cerr << j << " ";
cerr << endl;
*/
return nas;
}
Compilation message (stderr)
messy.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
messy_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |