Submission #799700

#TimeUsernameProblemLanguageResultExecution timeMemory
799700BenmathUnscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
9 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; std::vector<int> restore_permutation(int n, int w, int r) { vector<int>ans; for(int i=0;i<n;i++){ ans.push_back(0); } queue<pair<int,int>>q; q.push({0,n-1}); vector<string>cek; while(!q.empty()){ pair<int,int>ro=q.front(); q.pop(); if((ro.second-ro.first)>=1){ int a=ro.first; int b=ro.second; int ti=(a+b)/2; for(int i=a;i<=ti;i++){ string s=""; for(int j=0;j<a;j++){ s=s+'0'; } for(int j=a;j<=b;j++){ if(j!=i){ s=s+'1'; }else{ s=s+'0';} } for(int j=b+1;j<n;j++){ s=s+'0'; } // cout<<s<<endl; add_element(s); } q.push({a,ti}); q.push({ti+1,b}); } } queue<pair<pair<int,int>,vector<int>>>q1; vector<int>v; for(int i=0;i<n;i++){ v.push_back(i); } q1.push({{0,n-1},v}); compile_set(); while(!q1.empty()){ pair<pair<int,int>,vector<int>>ro=q1.front(); q1.pop(); int a=ro.first.first; int b=ro.first.second; v=ro.second; if(a==b){ ans[a]=v[0]; }else{ vector<int>v1; vector<int>v2; int ti=(a+b)/2; for(int i=a;i<=b;i++){ string s1=""; for(int j=0;j<a;j++){ s1=s1+'0'; } for(int j=a;j<=b;j++){ if(j!=i){ s1=s1+'1'; }else{ s1=s1+'0';} } for(int j=b+1;j<n;j++){ s1=s1+'0'; } if(check_element(s1)==true){ v1.push_back(i); }else{ v2.push_back(i);} } q1.push({{a,ti},v1}); q1.push({{ti+1,b},v2}); } } return ans; } /* int main(){ vector<int>ro=restore_permutation(8,12,12); } */
#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...