제출 #609690

#제출 시각아이디문제언어결과실행 시간메모리
609690sword060Unscrambling a Messy Bug (IOI16_messy)C++17
컴파일 에러
0 ms0 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; int* restore_permutation(int x, int w, int r){ int ans[10]; for(int i=0;i<x;i++)ans[i]=i+1; string p=""; for(int i=0;i<x;i++)p+='0'; for(int i=0;i<p.size();i++){ p[i]='1'; add_element(p); } compile_set(); for(int i=1;i<=(1LL<<x);i++){ string l=""; int xd=i,zz=8; while(zz--)l+=(xd%2?'1':'0'),xd/=2; reverse(l.begin(),l.end()); bool f=check_element(l); if(!f)continue; for(int i=0;i<x;i++){ if(l[i]!='1'||i==x-1||l[i+1]=='1')continue; for(int j=x-1;j>=i+2;j--){ if(l[j]=='0'){ swap(ans[j],ans[i]); return ans; } } } } return ans; }

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

messy.cpp:4:6: error: ambiguating new declaration of 'int* restore_permutation(int, int, int)'
    4 | int* restore_permutation(int x, 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);
      |                  ^~~~~~~~~~~~~~~~~~~
messy.cpp: In function 'int* restore_permutation(int, int, int)':
messy.cpp:9:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |   for(int i=0;i<p.size();i++){
      |               ~^~~~~~~~~
messy.cpp:26:18: warning: address of local variable 'ans' returned [-Wreturn-local-addr]
   26 |           return ans;
      |                  ^~~
messy.cpp:5:7: note: declared here
    5 |   int ans[10];
      |       ^~~
messy.cpp:31:10: warning: address of local variable 'ans' returned [-Wreturn-local-addr]
   31 |   return ans;
      |          ^~~
messy.cpp:5:7: note: declared here
    5 |   int ans[10];
      |       ^~~