제출 #420577

#제출 시각아이디문제언어결과실행 시간메모리
420577pliamUnscrambling a Messy Bug (IOI16_messy)C++14
컴파일 에러
0 ms0 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define MAXLOGN 7 #define MAXN 128 string extra_s[9],extra_f[9]; int logn,N,p[MAXN+1]; void p2write(int start,int end,int extra){ if(start==end) return; //write the first half with 1 int mid=(start+end)/2; string tmp=extra_s[extra]; for(int i=start;i<=mid;i++){ tmp[i-1]='1'; add_element(tmp); tmp[i-1]='0'; } p2write(start,mid,extra+1); p2write(mid+1,end,extra+1); } void bsearch(int k){//k>=logn(k is the position of the search element in p) int ext=1; int lo=logn+2,hi=N; while(lo<hi){ int mid=(lo+hi)/2; string tmp=extra_f[ext]; tmp[k]='1'; if(check_element(tmp)){ hi=mid; }else{ lo=mid+1; } ext++; } p[k]=lo-1; } int* restore_permutation(int n, int w, int r) { logn=log2(n); N=n; //first phase write for(int i=0;i<n;i++){ extra_s[0]+='0'; } for(int i=1;i<=logn+1;i++){ extra_s[i]=extra_s[i-1]; extra_s[i][i-1]='1'; add_element(extra_s[i]); } //second phase write p2write(logn+2,n,1); //compile set compile_set(); //first phase read extra_f[0]=extra_s[0]; for(int i=1;i<=logn+1;i++){ extra_f[i]=extra_f[i-1]; for(int j=0;j<n;j++){ if(extra_f[i][j]=='1') continue; extra_f[i][j]='1'; if(check_element(extra_f[i])){ p[j]=i-1; break; } extra_f[i][j]='0'; } } //second phase read for(int i=0;i<n;i++){ if(extra_f[logn+1][i]=='1') continue; bsearch(i); } //answer return std::vector<int>(p,p+n).data(); }

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp:41:6: error: ambiguating new declaration of 'int* restore_permutation(int, int, int)'
   41 | int* restore_permutation(int n, int w, int r) {
      |      ^~~~~~~~~~~~~~~~~~~
In file included from messy.cpp:1:
messy.h:10:18: note: old declaration 'std::vector<int> restore_permutation(int, int, int)'
   10 | std::vector<int> restore_permutation(int n, int w, int r);
      |                  ^~~~~~~~~~~~~~~~~~~