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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pii pair <int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
const int N = 100005;
const int mod = 1e9 + 7;
int a[N], sz;
string gen(){
    string s = "";
    for(int i = 0; i < sz; i++){
        if(a[i] == -1) s += '0';
        else s += '1';
    }
    return s;
}
vector<int> restore_permutation(int n, int w, int r) {
    string s = "";
    sz = n;
    for(int i = 1; i < n; i++){
        a[i] = -1;
        s = "";
        for(int j = i; j < n; j++) s += '0';
        for(int j = 0; j < i; j++) s += '1';
        add_element(s);
    }
    a[0] = -1;
    compile_set();
    for(int i = 1; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[j] == -1) a[j] = n - i;
            else continue;
            s = gen();
            if(check_element(s)){
                break;
            }
            else a[j] = -1;
        }
    }
    vector<int> ans;
    for(int i = 0; i < n; i++){
        if(a[i] == -1) a[i] = 0;
        ans.pb(a[i]);
    }
    return ans;
}
| # | 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... |