제출 #961230

#제출 시각아이디문제언어결과실행 시간메모리
961230Ahmed57Unscrambling a Messy Bug (IOI16_messy)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; string build(vector<int> x,int n){ string s; for(int i = 0;i<n;i++)s+='0'; for(auto i:x)s[i] = '1'; return s; } vector<int> restore_permutation(int n, int w, int r){ add_element(build(0)); for(int i = 1;i<n;i*=2){ for(int j = 0;j<n;j+=2*i){ vector<int> nah,nah2; for(int e = j;e<j+2*i;e++){ nah.push_back(e); } for(int e = j;e<=j+i;e++){ nah2.push_back(e); } add_element(nah); if(i==1&&j==0)continue; if(i==1){ nah2.pop_back(); nah2.push_back(0); add_element(nah2); continue; } add_element(nah2); } } compile_set(); vector<vector<int>> comps; int ind = 0; for(int i = 0;i<n;i++){ if(check_element(build(i))){ ind = i; } comps.push_back({i}); } while(comps.size()!=1){ vector<vector<int>> ncomps; for(int i = 0;i<comps.size();i++){ for(int j = i+1;j<comps.size();j++){ vector<int> comb,comb2,rev; for(auto e:comps[i])comb.push_back(e); for(auto e:comps[j])comb.push_back(e); for(auto e:comps[j])rev.push_back(e); for(auto e:comps[i])rev.push_back(e); for(auto e:comps[i])comb2.push_back(e); comb2.push_back(comps[j][0]); if(comps.size()==n){ comb2.pop_back(); comb2.push_back(ind); if(comps[i][0]==ind){ ncomps.push_back(comb); }else if(comps[j][0]==ind){ ncomps.push_back(rev); }else{ if(check_element(build(comb2))){ ncomps.push_back(comb); }else ncomps.push_back(rev); } }else{ if(check_element(build(comb2))){ ncomps.push_back(comb); }else ncomps.push_back(rev); } } } comps = ncomps; } return comps[0]; } /* int main(){ }*/

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

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:12:23: error: could not convert '0' from 'int' to 'std::vector<int>'
   12 |     add_element(build(0));
      |                       ^
      |                       |
      |                       int
messy.cpp:22:25: error: could not convert 'nah' from 'std::vector<int>' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   22 |             add_element(nah);
      |                         ^~~
      |                         |
      |                         std::vector<int>
messy.cpp:27:29: error: could not convert 'nah2' from 'std::vector<int>' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   27 |                 add_element(nah2);
      |                             ^~~~
      |                             |
      |                             std::vector<int>
messy.cpp:30:25: error: could not convert 'nah2' from 'std::vector<int>' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   30 |             add_element(nah2);
      |                         ^~~~
      |                         |
      |                         std::vector<int>
messy.cpp:37:32: error: could not convert 'i' from 'int' to 'std::vector<int>'
   37 |         if(check_element(build(i))){
      |                                ^
      |                                |
      |                                int
messy.cpp:44:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(int i = 0;i<comps.size();i++){
      |                       ~^~~~~~~~~~~~~
messy.cpp:45:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for(int j = i+1;j<comps.size();j++){
      |                             ~^~~~~~~~~~~~~
messy.cpp:53:32: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |                 if(comps.size()==n){
      |                    ~~~~~~~~~~~~^~~
messy.cpp:61:53: error: too few arguments to function 'std::string build(std::vector<int>, int)'
   61 |                         if(check_element(build(comb2))){
      |                                                     ^
messy.cpp:5:8: note: declared here
    5 | string build(vector<int> x,int n){
      |        ^~~~~
messy.cpp:66:49: error: too few arguments to function 'std::string build(std::vector<int>, int)'
   66 |                     if(check_element(build(comb2))){
      |                                                 ^
messy.cpp:5:8: note: declared here
    5 | string build(vector<int> x,int n){
      |        ^~~~~