Submission #894022

#TimeUsernameProblemLanguageResultExecution timeMemory
894022MalixUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms856 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define MP make_pair #include "messy.h" int m=0; vi ans; void solve(int a, int b, string &s){ REP(i,0,m)s[i]='1'; REP(i,a,b)s[i]='0'; REP(i,a,(a+b)/2){ s[i]='1'; add_element(s); s[i]='0'; } } void check(int a, int b, string &s,vi &p){ int g=p.size(); REP(i,0,m)s[i]='1'; REP(i,0,g)s[p[i]]='0'; REP(i,0,g){ s[p[i]]='1'; // cout<<s<<" "; bool x=check_element(s); if(x==0)ans[p[i]]=(a+b)/2; s[p[i]]='0'; } } std::vector<int> restore_permutation(int n, int w, int r) { string s; m=n; ans.resize(n,0); REP(i,0,n)s.PB('0'); int k=n; int a=0,b=0; while(k>1){ a=0;b=k; while(b<=n){ solve(a,b,s); a+=k;b+=k; } k/=2; } // add_element("0"); compile_set(); k=n;vi p; while(k>1){ a=0;b=k; while(b<=n){ REP(i,0,n)if(ans[i]==a)p.PB(i); check(a,b,s,p); a+=k;b+=k;p.clear(); } k/=2; } //check_element("0"); return ans; // return std::vector<int>(); }
#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...