답안 #591403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591403 2022-07-07T11:46:24 Z jasmin Unscrambling a Messy Bug (IOI16_messy) C++14
100 / 100
2 ms 468 KB
#include<bits/stdc++.h>
#include<messy.h>
using namespace std;

string voll="";

void insert(int n, vector<int>& a){
    if(a.size()<=1) return;

    /*cout << a.size() << "\n";
    for(auto e: a){
        cout << e << " ";
    }
    cout << "\n";*/

    string x=voll;
    for(auto e: a){
        x[e]='0';
    }
    for(int i=0; i<(int)a.size()/2; i++){
        x[a[i]]='1';
        add_element(x);
        x[a[i]]='0';
    }

    vector<int> a1;
    vector<int> a2;
    for(int i=0; i<(int)a.size(); i++){
        if(i<(int)a.size()/2){
            a1.push_back(a[i]);
        }
        else{
            a2.push_back(a[i]);
        }
    }
    insert(n, a1);
    insert(n, a2);
}

void solve(int n, vector<int>& a, vector<int>& b, vector<int>& p){
    if(a.size()==1){
        p[b[0]]=a[0];
        return;
    }

    string x=voll;
    vector<int> b1;
    vector<int> b2;
    for(auto e: b){
        x[e]='0';
    }
    for(auto e: b){
        x[e]='1';
        if(check_element(x)){
            b1.push_back(e);
        }
        else{
            b2.push_back(e);
        }
        x[e]='0';
    }

    vector<int> a1;
    vector<int> a2;
    for(int i=0; i<(int)a.size(); i++){
        if(i<(int)a.size()/2){
            a1.push_back(a[i]);
        }
        else{
            a2.push_back(a[i]);
        }
    }
    solve(n, a1, b1, p);
    solve(n, a2, b2, p);
}

vector<int> restore_permutation(int n, int w, int r){
    vector<int> b(n);
    iota(b.begin(), b.end(), 0);
    vector<int> a(n);
    iota(a.begin(), a.end(), 0);

    for(int i=0; i<n; i++){
        voll+="1";
    }

    insert(n, a);
    compile_set();
    vector<int> p(n);
    solve(n, a, b, p);
    return p;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 8
2 Correct 1 ms 212 KB n = 8
3 Correct 1 ms 300 KB n = 8
4 Correct 1 ms 212 KB n = 8
5 Correct 1 ms 212 KB n = 8
6 Correct 1 ms 212 KB n = 8
7 Correct 0 ms 212 KB n = 8
8 Correct 1 ms 212 KB n = 8
9 Correct 1 ms 212 KB n = 8
10 Correct 0 ms 296 KB n = 8
11 Correct 0 ms 212 KB n = 8
12 Correct 1 ms 212 KB n = 8
13 Correct 0 ms 212 KB n = 8
14 Correct 1 ms 212 KB n = 8
15 Correct 1 ms 212 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 32
2 Correct 1 ms 212 KB n = 32
3 Correct 1 ms 300 KB n = 32
4 Correct 1 ms 212 KB n = 32
5 Correct 1 ms 212 KB n = 32
6 Correct 1 ms 300 KB n = 32
7 Correct 0 ms 212 KB n = 32
8 Correct 1 ms 212 KB n = 32
9 Correct 1 ms 212 KB n = 32
10 Correct 1 ms 212 KB n = 32
11 Correct 1 ms 212 KB n = 32
12 Correct 1 ms 212 KB n = 32
13 Correct 1 ms 212 KB n = 32
14 Correct 1 ms 212 KB n = 32
15 Correct 1 ms 212 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 32
2 Correct 1 ms 212 KB n = 32
3 Correct 1 ms 212 KB n = 32
4 Correct 1 ms 300 KB n = 32
5 Correct 1 ms 212 KB n = 32
6 Correct 1 ms 212 KB n = 32
7 Correct 1 ms 212 KB n = 32
8 Correct 1 ms 300 KB n = 32
9 Correct 1 ms 212 KB n = 32
10 Correct 1 ms 212 KB n = 32
11 Correct 1 ms 212 KB n = 32
12 Correct 1 ms 212 KB n = 32
13 Correct 1 ms 212 KB n = 32
14 Correct 1 ms 212 KB n = 32
15 Correct 1 ms 212 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB n = 128
2 Correct 2 ms 468 KB n = 128
3 Correct 2 ms 468 KB n = 128
4 Correct 2 ms 468 KB n = 128
5 Correct 2 ms 428 KB n = 128
6 Correct 2 ms 468 KB n = 128
7 Correct 1 ms 468 KB n = 128
8 Correct 2 ms 468 KB n = 128
9 Correct 2 ms 468 KB n = 128
10 Correct 2 ms 468 KB n = 128
11 Correct 2 ms 468 KB n = 128
12 Correct 1 ms 468 KB n = 128
13 Correct 2 ms 468 KB n = 128
14 Correct 2 ms 424 KB n = 128
15 Correct 1 ms 468 KB n = 128
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB n = 128
2 Correct 1 ms 468 KB n = 128
3 Correct 2 ms 468 KB n = 128
4 Correct 1 ms 468 KB n = 128
5 Correct 1 ms 468 KB n = 128
6 Correct 2 ms 468 KB n = 128
7 Correct 1 ms 468 KB n = 128
8 Correct 2 ms 468 KB n = 128
9 Correct 1 ms 428 KB n = 128
10 Correct 1 ms 468 KB n = 128
11 Correct 2 ms 468 KB n = 128
12 Correct 2 ms 392 KB n = 128
13 Correct 2 ms 468 KB n = 128
14 Correct 2 ms 424 KB n = 128
15 Correct 1 ms 468 KB n = 128