Submission #861667

# Submission time Handle Problem Language Result Execution time Memory
861667 2023-10-16T16:01:48 Z TahirAliyev Unscrambling a Messy Bug (IOI16_messy) C++17
0 / 100
1 ms 604 KB
#include <vector>
#include <bits/stdc++.h>
#include "messy.h"

using namespace std;

const int MAX = 130;

void write(int l, int r, int n){
    if(l == r) return;
    string s = "";
    for(int i = 0; i < n; i++){
        if(l <= i && i <= r){
            s += '0';
        }
        else{
            s += '1';
        }
    }
    int mid = (l + r) / 2;
    for(int i = l; i <= mid; i++){
        s[i] = '1';
        add_element(s);
        s[i] = '0';
    }
    write(l, mid, n);
    write(mid + 1, r, n);
}

int p[MAX];

void read(int l, int r, vector<int> inc, int n){
    if(l == r){
        p[inc[0]] = l;
        return;
    }
    string s = "";
    for(int i = 0; i < n; i++){
        s += '1';
    }
    for(int a : inc){
        s[a] = '0';
    }
    int mid = (l + r) / 2;
    vector<int> lv, rv;
    for(int i : inc){
        s[i] = '1';
        if(check_element(s)){
            lv.push_back(i);
        }
        else{
            rv.push_back(i);
        }
        s[i] = '0';
    }
    read(l, mid, lv, n);
    read(mid + 1, r, rv, n);
}

vector<int> restore_permutation(int n, int w, int r) {
    write(0, n - 1, n);
    compile_set();
    vector<int> tmp;
    for(int i = 0; i < n; i++) tmp.push_back(i);
    read(0, n - 1, tmp, n);
    vector<int> res;
    for(int i = 0; i < n; i++){
        res.push_back(p[i]);
        cout << p[i] << ' ';
    } 
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 352 KB Wrong secret!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 360 KB Wrong secret!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong secret!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Wrong secret!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Wrong secret!
2 Halted 0 ms 0 KB -