Submission #609693

#TimeUsernameProblemLanguageResultExecution timeMemory
609693sword060Unscrambling a Messy Bug (IOI16_messy)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> restore_permutation(int x, int w, int r){ vector<int> ans(x); for(int i=0;i<x;i++)ans[i]=i+1; string p=""; for(int i=0;i<x;i++)p+='0'; for(int i=0;i<p.size();i++){ p[i]='1'; add_element(p); } compile_set(); for(int i=1;i<=(1LL<<x);i++){ string l=""; int xd=i,zz=8; while(zz--)l+=(xd%2?'1':'0'),xd/=2; reverse(l.begin(),l.end()); bool f=check_element(l); if(!f)continue; for(int i=0;i<x;i++){ if(l[i]!='1'||i==x-1||l[i+1]=='1')continue; for(int j=x-1;j>=i+2;j--){ if(l[j]=='0'){ swap(ans[j],ans[i]); return ans; } } } } return ans; }

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:8:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |   for(int i=0;i<p.size();i++){
      |               ~^~~~~~~~~
messy.cpp:10:5: error: 'add_element' was not declared in this scope
   10 |     add_element(p);
      |     ^~~~~~~~~~~
messy.cpp:12:3: error: 'compile_set' was not declared in this scope
   12 |   compile_set();
      |   ^~~~~~~~~~~
messy.cpp:18:12: error: 'check_element' was not declared in this scope
   18 |     bool f=check_element(l);
      |            ^~~~~~~~~~~~~