답안 #1074465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074465 2024-08-25T10:39:15 Z YassineBenYounes Unscrambling a Messy Bug (IOI16_messy) C++17
20 / 100
2 ms 604 KB
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pb push_back



int sz;
vector<string> ask;
vi res;
void preprocess(int l, int r){
    if(l == r)return;
    string s(sz, '0');
    for(int i = 0; i < l;i++){
        s[i] = '1';
    }
    for(int i = r+1; i < sz;i++){
        s[i] = '1';
    }
    int md = (l+r)/2;
    for(int i = l;i <= md;i++){
        s[i] = '1';
        ask.pb(s);
        s[i] = '0';
    }
    preprocess(l, md);
    preprocess(md+1, r);
}

string cur;

void solve(int l, int r, set<int> possible){
    if(possible.size() == 1){
        res[l] = *possible.begin();
        return;
    }
    set<int> left;
    for(int x : possible){
        cur[x] = '1';
        //cout << cur << endl;
        bool k = check_element(cur);
        
        if(k){
            left.insert(x);
        }
        cur[x] = '0';
    }
    set<int> right = possible;
    for(int x : left){
        right.erase(x);
    }
    int md = (l+r)/2;
    for(int x : right){
        cur[x] = '1';
    }
    solve(l, md, left);
    for(int x : right){
        cur[x] = '0';
    }
    for(int x : left){
        cur[x] = '1';
    }
    solve(md+1, r, right);
    for(int x : left){
        cur[x] = '0';
    }
}

std::vector<int> restore_permutation(int N, int w, int r) {
    sz = N;
    preprocess(0, sz-1);
    for(string s: ask){
        //cout << s << endl;
        add_element(s);
    }
    compile_set();
    res.resize(sz);
    //cout << endl;
    //res = {7, 6, 5, 4, 3, 2, 1, 0};
    set<int> mys;
    for(int i = 0; i < sz;i++){
        mys.insert(i);
    }
    cur.resize(sz, '0');
    solve(0, sz-1, mys);
    return res;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB n = 8
2 Correct 1 ms 348 KB n = 8
3 Correct 0 ms 348 KB n = 8
4 Correct 1 ms 348 KB n = 8
5 Correct 1 ms 348 KB n = 8
6 Correct 0 ms 348 KB n = 8
7 Correct 0 ms 348 KB n = 8
8 Correct 0 ms 348 KB n = 8
9 Correct 1 ms 348 KB n = 8
10 Correct 1 ms 348 KB n = 8
11 Correct 0 ms 348 KB n = 8
12 Correct 0 ms 348 KB n = 8
13 Correct 1 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB n = 32
2 Correct 1 ms 348 KB n = 32
3 Correct 1 ms 348 KB n = 32
4 Incorrect 0 ms 348 KB grader returned WA
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB grader returned WA
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB grader returned WA
2 Halted 0 ms 0 KB -