제출 #308937

#제출 시각아이디문제언어결과실행 시간메모리
308937amunduzbaevUnscrambling a Messy Bug (IOI16_messy)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "messy.h" //#include "grader.cpp" vector<string>v; int n; string bin(int a){ string s; while(a){ int d=a%2; s.push_back(d+'0'); a/=2; } while(s.size() < n){ s.push_back('0'); } reverse(s.begin(),s.end()); return s; } void add(){ string s; s[0]='0'; for(int i=1;i<n;i++) s[i]='1'; int last=1; for(int i=0;i<n-1;i++){ add_const(s); s[last]='0'; last++; } } int p(int b){ int a=1; while(b--) a*=2; return a; } void check(){ int num=0; string s; for(int i=1;i<p(n);i++){ num++; s=(bin(num)); if(check_element(s)) v.push_back(s); } } vector<int> restore_permutation(int N, int w, int r) { n=N; add(); compile_set(); check(); vector<int>ans(n,0),a(n,0); for(int i=0;i<v.size();i++){ for(int j=0;j<n;j++){ a[j]+=(v[i][j]-'0'); } } for(int i=0;i<n;i++){ ans[a[i]]=i; } for(int i=0;i<n;i++) cout<<a[i]<<" "; return ans; } /* 4 16 16 1 3 2 0 */

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

messy.cpp: In function 'std::string bin(int)':
messy.cpp:18:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while(s.size() < n){
      |           ~~~~~~~~~^~~
messy.cpp: In function 'void add()':
messy.cpp:32:18: error: missing template arguments before '(' token
   32 |         add_const(s);
      |                  ^
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
messy.cpp:66:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   66 |     for(int i=0;i<n;i++)
      |     ^~~
messy.cpp:68:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   68 |         return ans;
      |         ^~~~~~