Submission #207909

#TimeUsernameProblemLanguageResultExecution timeMemory
207909DodgeBallManUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> vec; int n, p[150]; string element( int l, int r, int idx ) { string s( n, '1' ); for( int i = l ; i <= r ; i++ ) s[i] = '0'; s[idx] = '1'; return s; } string question( vector<int> &v, int idx ) { string s( n, '1' ); for( int i : v ) s[i] = '0'; s[idx] = '1'; return s; } void add( int l = 0, int r = n - 1 ) { if( l == r ) return ; int mid = l + r >> 1; for( int i = l ; i <= mid ; i++ ) add_element( element( l, r, i ) ); add( l, mid ), add( mid + 1, r ); } void solve( vector<int> &v, int l = 0, int r = n - 1 ) { if( l == r ) return void( p[v[0]] = l ); vector<int> le, ri; for( int i : v ) { bool side = check_element( question( v, i ) ); if( side ) le.emplace_back( i ); else ri.emplace_back( i ); } int mid = l + r >> 1; solve( le, l, mid ), solve( ri, mid + 1, r ); } int restore_permutation( int N, int w, int r ) { n = N; add(), compile_set(); for( int i = 0 ; i < n ; i++ ) vec.emplace_back( i ); solve( vec ); return p; }

Compilation message (stderr)

messy.cpp: In function 'void add(int, int)':
messy.cpp:24:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
messy.cpp: In function 'void solve(std::vector<int>&, int, int)':
messy.cpp:37:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
messy.cpp: In function 'int restore_permutation(int, int, int)':
messy.cpp:41:5: error: ambiguating new declaration of 'int restore_permutation(int, int, int)'
 int restore_permutation( int N, int w, int r ) {
     ^~~~~~~~~~~~~~~~~~~
In file included from messy.cpp:2:0:
messy.h:10:18: note: old declaration 'std::vector<int> restore_permutation(int, int, int)'
 std::vector<int> restore_permutation(int n, int w, int r);
                  ^~~~~~~~~~~~~~~~~~~
messy.cpp:46:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
     return p;
            ^