Submission #370165

#TimeUsernameProblemLanguageResultExecution timeMemory
370165leinad2Unscrambling a Messy Bug (IOI16_messy)C++17
Compilation error
0 ms0 KiB
#include "messy.h" #include<bits/stdc++.h> using namespace std; vector<int>ans; void add(int l, int r) { if(l==r)return; int m=l+r>>1; for(int j=l;j<=m;j++) { string s; for(int i=0;i++<n;) { if(l<=i&&i<=r) { if(i==j)s+='1'; else s+='0'; } else s+='1'; } add_element(s); } add(l, m); add(m+1, r); } void chk(int l, int r, vector<int>v) { if(l==r) { ans[v[0]-1]=l-1; return; } int m=l+r>>1; vector<int>L, R; int A[130]={}; for(int i=0;i<v.size();i++) { A[v[i]]=1; } for(int i=0;i<v.size();i++) { string s; for(int j=0;j++<n;) { if(A[j]) { if(j==v[i])s+='1'; else s+='0'; } else s+='1'; } if(check_element(s))L.push_back(v[i]); else R.push_back(v[i]); } chk(l, m, L); chk(m+1, r, R); } vector<int>restore_permutation(int n, int w, int r) { ans.resize(n); vector<int>v;for(int i=0;i++<n;)v.push_back(i); add(1, n); compile_set(); chk(1, n, v); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void add(int, int)':
messy.cpp:8:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    8 |     int m=l+r>>1;
      |           ~^~
messy.cpp:12:25: error: 'n' was not declared in this scope
   12 |         for(int i=0;i++<n;)
      |                         ^
messy.cpp: In function 'void chk(int, int, std::vector<int>)':
messy.cpp:33:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |     int m=l+r>>1;
      |           ~^~
messy.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
messy.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
messy.cpp:43:25: error: 'n' was not declared in this scope
   43 |         for(int j=0;j++<n;)
      |                         ^