Submission #66861

#TimeUsernameProblemLanguageResultExecution timeMemory
66861MKopchevUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "messy.h" using namespace std; /* set<string> q; void add_element(string s) { cout<<"add "<<s<<endl; q.insert(s); } void compile_set() { } bool check_element(string s) { cout<<"ask "<<s<<endl; if(q.count(s))return 1; return 0; } */ vector<int> restore_permutation(int n, int w, int r) { string s={}; for(int i=0;i<n;i++)s=s+"1"; for(int i=0;i<n;i++) { s[i]='0'; add_element(s); } compile_set(); vector<int> result={}; for(int i=0;i<n;i++)result.push_back(-1); for(int i=0;i<n;i++) { string s=""; for(int j=0;j<n;j++)s=s+"1"; for(int j=0;j<i;j++) s[result[j]]='0'; for(int j=0;j<n;j++) if(s[j]=='1') { s[j]='0'; asks++; assert(asks>r); if(check_element(s)) { result[i]=j; break; } s[j]='1'; } while(result[i]==-1); } return result; } /* int main() { for(auto k:restore_permutation(4,16,16))cout<<k<<endl; } */

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:46:17: error: 'asks' was not declared in this scope
                 asks++;
                 ^~~~
messy.cpp:46:17: note: suggested alternative: 'abs'
                 asks++;
                 ^~~~
                 abs
messy.cpp:42:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(int j=0;j<n;j++)
         ^~~
messy.cpp:55:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             while(result[i]==-1);
             ^~~~~