Submission #31722

#TimeUsernameProblemLanguageResultExecution timeMemory
31722top34051Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
5 ms640 KiB
#include "messy.h" #include<bits/stdc++.h> using namespace std; string s; vector<int> pos[900], perm, ans; void init(int n,int l,int r) { if(l==r) return ; int mid = (l+r)/2; for(int i=0;i<n;i++) s[i] = '1'; for(int i=l;i<=r;i++) s[i] = '0'; for(int i=l;i<=mid;i++) { s[i] = '1'; // cout << "add_element: " << s << endl; add_element(s); s[i] = '0'; } init(n,l,mid); init(n,mid+1,r); } void query(int n,int now,int l,int r) { // printf("query %d %d\n",l,r); if(l==r) { perm[l] = pos[now][0]; return ; } int mid = (l+r)/2; for(int i=0;i<n;i++) s[i] = '1'; for(int i=0;i<pos[now].size();i++) s[pos[now][i]] = '0'; for(int i=0;i<pos[now].size();i++) { int x = pos[now][i]; s[x] = '1'; int temp = check_element(s); // cout << "check_element: " << s << " = " << temp << endl; s[x] = '0'; if(temp==1) pos[now<<1].push_back(x); else pos[now<<1|1].push_back(x); } query(n,now<<1,l,mid); query(n,now<<1|1,mid+1,r); } std::vector<int> restore_permutation(int n, int w, int r) { for(int i=0;i<n;i++) s += "0"; init(n,0,n-1); compile_set(); for(int i=0;i<n;i++) perm.push_back(-1), pos[1].push_back(i); query(n,1,0,n-1); for(int i=0;i<n;i++) ans.push_back(-1); for(int i=0;i<n;i++) ans[perm[i]] = i; return ans; }

Compilation message (stderr)

messy.cpp: In function 'void query(int, int, int, int)':
messy.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<pos[now].size();i++) s[pos[now][i]] = '0';
                 ~^~~~~~~~~~~~~~~~
messy.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<pos[now].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...