Submission #979332

# Submission time Handle Problem Language Result Execution time Memory
979332 2024-05-10T16:18:08 Z hariaakas646 Unscrambling a Messy Bug (IOI16_messy) C++14
100 / 100
2 ms 856 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
#include "messy.h"

int n;

void build(int l, int r) {
    if(l >= r) return;
    int mid = (l+r)/2;
    string str="";
    frange(i, n) str += "1";
    forr(i, l, r+1) str[i] = '0';
    forr(i, l, mid+1) {
        str[i] = '1';
        // cout << l << " " << r << " " << i << " "<< str << "\n";
        add_element(str);
        str[i] = '0';
    }
    build(l, mid);
    build(mid+1, r);
}

vi out;

void query(int l, int r, vi vec) {
    if(l == r) {
        // if(vec.size())
        out[vec[0]] = l;
        return;
    }
    int mid = (l+r)/2;
    string str="";
    frange(i, n) str += "1";
    for(auto i : vec) str[i] = '0';
    vi lv, rv;
    for(auto e : vec) {
        str[e] = '1';
        if(check_element(str)) lv.pb(e);
        else rv.pb(e);
        str[e] = '0';
    }
    query(l, mid, lv);
    query(mid+1, r, rv);
}

std::vector<int> restore_permutation(int N, int w, int r) {
    n = N;
    build(0, n-1);
    compile_set();
    vi vec;
    frange(i, n) vec.pb(i);
    out = vi(n);
    query(0, n-1, vec);
    return out;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 8
2 Correct 0 ms 348 KB n = 8
3 Correct 0 ms 348 KB n = 8
4 Correct 0 ms 348 KB n = 8
5 Correct 0 ms 348 KB n = 8
6 Correct 1 ms 348 KB n = 8
7 Correct 1 ms 348 KB n = 8
8 Correct 0 ms 348 KB n = 8
9 Correct 0 ms 348 KB n = 8
10 Correct 0 ms 348 KB n = 8
11 Correct 0 ms 348 KB n = 8
12 Correct 0 ms 344 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 1 ms 348 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 1 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 1 ms 348 KB n = 32
6 Correct 0 ms 348 KB n = 32
7 Correct 1 ms 348 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 1 ms 348 KB n = 32
10 Correct 0 ms 432 KB n = 32
11 Correct 0 ms 348 KB n = 32
12 Correct 0 ms 348 KB n = 32
13 Correct 0 ms 348 KB n = 32
14 Correct 1 ms 348 KB n = 32
15 Correct 0 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 32
2 Correct 1 ms 600 KB n = 32
3 Correct 1 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 1 ms 348 KB n = 32
6 Correct 0 ms 348 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 1 ms 348 KB n = 32
9 Correct 0 ms 432 KB n = 32
10 Correct 1 ms 348 KB n = 32
11 Correct 1 ms 432 KB n = 32
12 Correct 0 ms 348 KB n = 32
13 Correct 1 ms 348 KB n = 32
14 Correct 0 ms 348 KB n = 32
15 Correct 1 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB n = 128
2 Correct 1 ms 604 KB n = 128
3 Correct 1 ms 604 KB n = 128
4 Correct 1 ms 604 KB n = 128
5 Correct 2 ms 856 KB n = 128
6 Correct 1 ms 604 KB n = 128
7 Correct 2 ms 492 KB n = 128
8 Correct 1 ms 636 KB n = 128
9 Correct 1 ms 604 KB n = 128
10 Correct 1 ms 604 KB n = 128
11 Correct 1 ms 604 KB n = 128
12 Correct 1 ms 432 KB n = 128
13 Correct 1 ms 604 KB n = 128
14 Correct 1 ms 856 KB n = 128
15 Correct 1 ms 604 KB n = 128
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB n = 128
2 Correct 1 ms 600 KB n = 128
3 Correct 1 ms 604 KB n = 128
4 Correct 1 ms 600 KB n = 128
5 Correct 1 ms 604 KB n = 128
6 Correct 1 ms 600 KB n = 128
7 Correct 1 ms 600 KB n = 128
8 Correct 1 ms 604 KB n = 128
9 Correct 1 ms 604 KB n = 128
10 Correct 2 ms 604 KB n = 128
11 Correct 1 ms 604 KB n = 128
12 Correct 1 ms 604 KB n = 128
13 Correct 1 ms 604 KB n = 128
14 Correct 1 ms 604 KB n = 128
15 Correct 1 ms 604 KB n = 128