이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
#define X first
#define Y second
#define pb push_back
int k[10][200];
vector<int> reza;
std::vector<int> restore_permutation(int n, int w, int r) {
    //add_element("0");
    //compile_set();
    //check_element("0");
    reza.resize(n);
    
    string s(n, '0');
    for (int i = 0; i < n / 2; i++) {
    	s[i] = '1';
    	add_element(s);
    	s[i] = '0';
    }
    for (int m = n / 2; m >= 2; m /= 2) {
    	string t(n, '1');
    	for (int i = 0; i < n; i += m) {
    		for (int j = i; j < i + m; j++) {
    			t[j] = '0';
    		}
    		for (int j = i; j < i + m / 2; j++) {
    			t[j] = '1';
    			add_element(t);
    			t[j] = '0';
    		}
    		for (int j = i; j < i + m; j++) {
    			t[j] = '1';
    		}
    	}
    }
    compile_set();
    int i1 = 0, i2 = n / 2;
    for (int i = 0; i < n; i++) {
    	s[i] = '1';
    	if (!check_element(s)) {
    		k[0][i1] = i;
    		reza[i] |= n / 2;
    		i1++;
    	} else {
    		k[0][i2] = i;
    		i2++;
    	}
    	s[i] = '0';
    }
    
    int kk = 1;
    
    for (int m = n / 2; m >= 2; m /= 2) {
    	string t(n, '1');
    	for (int i = 0; i < n; i += m) {
    		for (int j = i; j < i + m; j++) {
    			t[k[kk - 1][j]] = '0';
    		}
    		i1 = i; i2 = i + m / 2;
    		for (int j = 0; j < n; j++) {
    			if (t[j] == '1') continue;
    			t[j] = '1';
    			if (!check_element(t)) {
    				k[kk][i1] = j;
    				reza[j] |= m / 2;
    				i1++;
    			} else {
    				k[kk][i2] = j;
    				i2++;
    			}
    			t[j] = '0';
    		}
    		for (int j = i; j < i + m; j++) {
    			t[k[kk - 1][j]] = '1';
    		}
    	}
    	kk += 1;
    }
    
    return reza;
    //return std::vector<int>();
}
| # | 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... |