답안 #982159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982159 2024-05-14T01:32:43 Z beaboss Unscrambling a Messy Bug (IOI16_messy) C++14
100 / 100
2 ms 852 KB
#include "bits/stdc++.h"
#include "messy.h"
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; i++)
typedef vector<int> vi;

#define pb push_back

int n;
int ind = 0;
void ins(int l, int dep = n) {
    if (dep == 1) return;
    // cout << l << dep << endl;
    string cur;
    FOR(i, 0, l) cur += '1';
    FOR(i, l, l + dep) cur += '0';
    FOR(i, l + dep, n) cur += '1';

    FOR(i, l, l + dep/2) {
        cur[i] = '1';
        add_element(cur);
        // cout << cur << endl;
        cur[i] = '0';
    }

    ins(l, dep/2);
    ins(l + dep/2, dep/2);
}
vi res;
void solve(vector<int> state) {
    if (state.size() == 1) {
        res[state[0]] = ind++;
        return; 
    }
    // for (auto val: state) {
    //     cout << val << ' ';
    // }
    // cout << endl;
    string cur;
    FOR(i, 0, n) cur += '1';
    for (auto val: state) cur[val] = '0';
    vector<int> w, wo;
    for (auto val: state) {
        cur[val] = '1';
        // cout << check_element(cur) << endl;
        if (check_element(cur)) w.pb(val);
        else wo.pb(val);
        cur[val] = '0';
    }
    // return;
    solve(w);
    solve(wo);
}


vector<int> restore_permutation(int nn, int w, int r) {
    n = nn;
    ins(0, n);
    compile_set();
    
    vi f;
    FOR(i, 0, n) f.pb(i);
    res.resize(n);

    solve(f);

    return res;
}

// int main() {
//     n = 8;
//     ins(0);
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n = 8
2 Correct 0 ms 348 KB n = 8
3 Correct 0 ms 440 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 0 ms 344 KB n = 8
8 Correct 0 ms 348 KB n = 8
9 Correct 1 ms 352 KB n = 8
10 Correct 0 ms 344 KB n = 8
11 Correct 0 ms 344 KB n = 8
12 Correct 0 ms 348 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 1 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 1 ms 436 KB n = 32
3 Correct 0 ms 344 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 1 ms 348 KB n = 32
9 Correct 0 ms 348 KB n = 32
10 Correct 0 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 344 KB n = 32
14 Correct 0 ms 348 KB n = 32
15 Correct 1 ms 348 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 0 ms 424 KB n = 32
5 Correct 0 ms 348 KB n = 32
6 Correct 1 ms 344 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 1 ms 348 KB n = 32
9 Correct 1 ms 348 KB n = 32
10 Correct 1 ms 344 KB n = 32
11 Correct 1 ms 348 KB n = 32
12 Correct 0 ms 348 KB n = 32
13 Correct 0 ms 348 KB n = 32
14 Correct 0 ms 348 KB n = 32
15 Correct 0 ms 348 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB n = 128
2 Correct 1 ms 604 KB n = 128
3 Correct 1 ms 600 KB n = 128
4 Correct 1 ms 600 KB n = 128
5 Correct 1 ms 604 KB n = 128
6 Correct 1 ms 436 KB n = 128
7 Correct 1 ms 600 KB n = 128
8 Correct 1 ms 604 KB n = 128
9 Correct 2 ms 600 KB n = 128
10 Correct 1 ms 600 KB n = 128
11 Correct 1 ms 600 KB n = 128
12 Correct 2 ms 600 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
# 결과 실행 시간 메모리 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 604 KB n = 128
6 Correct 1 ms 604 KB n = 128
7 Correct 1 ms 604 KB n = 128
8 Correct 1 ms 604 KB n = 128
9 Correct 1 ms 604 KB n = 128
10 Correct 1 ms 852 KB n = 128
11 Correct 1 ms 600 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