Submission #370166

#TimeUsernameProblemLanguageResultExecution timeMemory
370166leinad2Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms640 KiB
#include "messy.h" #include<bits/stdc++.h> using namespace std; vector<int>ans; int n; 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) { n=N; 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:9:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |     int m=l+r>>1;
      |           ~^~
messy.cpp: In function 'void chk(int, int, std::vector<int>)':
messy.cpp:34:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |     int m=l+r>>1;
      |           ~^~
messy.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
messy.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...