Submission #125738

#TimeUsernameProblemLanguageResultExecution timeMemory
125738Nodir_BobievUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
# include <iostream> # include <vector> # include <algorithm> using namespace std; vector < string > vc; vector < int > tri[128][130], p = {0,3,5,1,2,7,4,6}; string zeros, ones; /* void add_element( string s ) { string nw; for( auto c: p ){ nw += s[c]; } vc.push_back( nw ); } void print_elements() { for( auto c: vc ){ cout << c << endl; } } bool check_element( string s ) { for( auto c: vc ){ if( c == s ){ return true; } } return false; } */ void rec( int i, int j ) { if( j == 1 ) return; string ss = ones; for( auto c: tri[i][j] )ss[c] = '0'; for( auto c: tri[i][j] ){ string s = ss; s[c] = '1'; if( check_element( s ) ){ tri[i][j/2].push_back( c ); }else{ tri[i+j/2][j/2].push_back( c ); } } rec( i, j/2 ); rec( i+j/2, j/2); } vector <int> restor_permutation( int n, int w, int r ) { for( int i = 0; i < n; i ++ ){ zeros += '0'; ones += '1'; } for( int i = 2; i <= n; i *= 2 ){ for( int j = 0; j < n; j += i ){ string s = zeros; for( int k = 0; k < j; k ++ ) s[k] = '1'; for( int k=j+i; k < n; k ++ ) s[k] = '1'; for( int k = j; k<j+i/2; k ++ ){ s[k] = '1'; add_element( s ); s[k] = '0'; } } } for( int i = 0; i < n; i ++ ) tri[0][n].push_back( i ); rec( 0, n ); vector < pair < int, int > > st; for( int i = 0; i < n; i ++ ){ st.push_back( make_pair( tri[i][1][0], i ) ); } sort( st.begin(), st.end() ); vector < int > ret; for( auto c: st ){ ret.push_back( c.second ); } return ret; } /* int main() { vector < int > ans; ans = restor_permutation( 8,8,8 ); for( auto c: ans ){ cout << c << ' '; } return 0; } */

Compilation message (stderr)

messy.cpp: In function 'void rec(int, int)':
messy.cpp:47:13: error: 'check_element' was not declared in this scope
         if( check_element( s ) ){
             ^~~~~~~~~~~~~
messy.cpp: In function 'std::vector<int> restor_permutation(int, int, int)':
messy.cpp:71:17: error: 'add_element' was not declared in this scope
                 add_element( s );
                 ^~~~~~~~~~~