# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537672 | Cross_Ratio | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 2 ms | 468 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#include "messy.h"
using namespace std;
void add_element(string);
void compile_set();
bool check_element(string);
bool type[130][9];
void DnC(int s, int e, string S, int lev) {
if(e==s+1) return;
int mid = (s + e) / 2;
int i;
for(i=s;i<e;i++) {
S[i] = '0';
}
for(i=s;i<mid;i++) {
S[i] = '1';
/*cout << "Push ";
for(int j=0;j<S.length();j++) cout <<S[j];
cout << '\n';*/
add_element(S);
S[i] = '0';
type[i][lev] = true;
}
for(i=s;i<mid;i++) S[i] = '1';
DnC(mid, e, S, lev+1);
for(i=s;i<mid;i++) S[i] = '0';
for(i=mid;i<e;i++) S[i] = '1';
DnC(s, mid, S, lev+1);
}
vector<vector<int>> seg;
void DnC2(string S, int n) {
if(n>=seg.size()/2) return;
int i;
vector<int> A, B;
for(int k : seg[n]) {
S[k] = '0';
}
for(int k : seg[n]) {
S[k] = '1';
bool m = check_element(S);
/*for(int j = 0; j < S.length();j++) cout << S[j];
cout << " : ? " << (m ? "True\n" : "False\n");*/
S[k] = '0';
if(m) seg[2*n].push_back(k);
else seg[2*n+1].push_back(k);
}
for(int k : seg[2*n]) {
S[k] = '1';
}
DnC2(S, 2*n+1);
for(int k : seg[2*n]) S[k] = '0';
for(int k : seg[2*n+1]) S[k] = '1';
DnC2(S, 2*n);
}
vector<int> restore_permutation(int N, int W, int R) {
string S;
S.resize(N);
int i, j, k, a, b, c;
DnC(0, N, S, 0);
compile_set();
seg.resize(2*N);
for(i=0;i<N;i++) seg[1].push_back(i);
for(i=0;i<N;i++) S[i] = '0';
DnC2(S, 1);
vector<int> V;
V.resize(N);
for(i=0;i<N;i++) {
V[seg[i+N][0]] = i;
}
/*for(i=1;i<2*N;i++) {
cout << i << " th Set\n";
for(int k : seg[i]) cout << k << ' ';
cout << '\n';
}*/
return V;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |