제출 #40988

#제출 시각아이디문제언어결과실행 시간메모리
40988MatheusLealVUnscrambling a Messy Bug (IOI16_messy)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; int* restore_permutation(int N_, int w, int r) { n = N_; int *ans = new int[n]; for(int i = 0; i < n; i++) ans[i] = -1; for(int i = 0; i < n; i++) { string s = ""; int qtd = i + 1; for(int p = 0; p < n; p++) { if(qtd > 0) s.push_back('1'); else s.push_back('0'); qtd --; } reverse(s.begin(), s.end()); add_element(s); //cout<<"ADD "<<s<<"\n"; } compile_set(); //memset(ans, -1, sizeof ans); string ant = ""; for(int i = 0; i < n; i++) ant.push_back('0'); for(int bit = 1, pos = n - 1; bit <= n; bit ++, pos --) { vector<string> all; for(int i = 0; i < n; i++) { if(ant[i] == '0') { string aux = ant; aux[i] = '1'; all.push_back(aux); } } //random_shuffle(all.begin(), all.end()); bool jafoi = false; for(auto s: all) { if(jafoi) break; if(check_element(s)) { //cout<<s<<"\n"; for(int i = 0; i < s.size(); i++) { if(s[i] == '1' && ans[i] == -1) { ans[i] = pos; jafoi = true; break; } } ant = s; } } } return ans; }

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

messy.cpp: In function 'int* restore_permutation(int, int, int)':
messy.cpp:7:6: 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:73:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < s.size(); i++)
                    ~~^~~~~~~~~~