Submission #30464

#TimeUsernameProblemLanguageResultExecution timeMemory
30464bilelgUnscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
3 ms512 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void Reverse(string & s, int i) { s[i] = '1'-s[i]+'0'; } vector<int> restore_permutation(int n, int w, int r) { string s(n,'0'); /*for(int i=0;i<n;i++) s[i]='0';*/ int bitmask = n>>1; while(bitmask>0) { string S(s); fill(s.begin(),s.end(),'0'); for(int i=0;i<n;i++) if(i&bitmask) { Reverse(S,i); add_element(S); Reverse(S,i); s[i] = '1'; } bitmask>>=1; } fill(s.begin(),s.end(),'1'); s[2] = '0'; add_element(s); compile_set(); fill(s.begin(),s.end(),'0'); vector<int> p(n,0); bitmask = n>>1; //set<string>used; while(bitmask>0) { string S(s); fill(s.begin(),s.end(),'0'); for(int i=1;i<n;i++) { Reverse(S,i); //if(used.find(S)==used.end()) if(check_element(S)) { p[i]+=bitmask; s[i] = '1'; //used.insert(S); } Reverse(S,i); } bitmask>>=1; } fill(s.begin(),s.end(),'1'); for(int i=0;i<n;i++) { Reverse(s,i); if(check_element(s)) { p[i]=2; break; } Reverse(s,i); } int exist[n]; memset(exist,0,sizeof exist); for(int i=0;i<n;i++) exist[p[i]] = 1; for(int i=0;i<n;i++) if(exist[i]==0) { p[0]=i; break; } #ifdef debug for(int x:p) cout<<x<<" "; #endif return p; }
#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...