답안 #308535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308535 2020-10-01T13:46:15 Z talant117408 Unscrambling a Messy Bug (IOI16_messy) C++17
100 / 100
3 ms 512 KB
#include "messy.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

vector <int> per;
map <pii, vector <int>> which, which2;

void insertit(int l, int r, int n){
    if(l == r) return;
    
    int mid = (l+r) >> 1, i;
    
    string in = "";
    for(i = 0; i < n; i++)
        in += "1";
    for(i = l; i <= r; i++)
        in[i] = '0';
        
    for(i = l; i <= mid; i++){
        in[i] = '1';
        add_element(in);
        in[i] = '0';
    }
    
    insertit(l, mid, n);
    insertit(mid+1, r, n);
}

void find(int l, int r, int n, vector <int> v){
    if(l == r){
        per[v[0]] = l;
        return;
    }
    
    int mid = (l+r) >> 1, i;
    
    string in = "";
    for(i = 0; i < n; i++)
        in += "1";
        
    for(auto to : v) in[to] = '0';
    
    vector <int> lll, rrr;
    
    for(auto to : v){
        in[to] = '1';
        
        (check_element(in) ? lll : rrr).pb(to);
        
        in[to] = '0';
    }
    
    find(l, mid, n, lll);
    find(mid+1, r, n, rrr);
}

vector<int> restore_permutation(int n, int w, int r) {
    per.resize(n, -1);
    vector <int> v(n);
    iota(all(v), 0);
    insertit(0, n-1, n);
    compile_set();
    find(0, n-1, n, v);
    
    return per;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB n = 8
2 Correct 0 ms 256 KB n = 8
3 Correct 0 ms 256 KB n = 8
4 Correct 1 ms 384 KB n = 8
5 Correct 0 ms 256 KB n = 8
6 Correct 0 ms 256 KB n = 8
7 Correct 1 ms 384 KB n = 8
8 Correct 0 ms 256 KB n = 8
9 Correct 0 ms 256 KB n = 8
10 Correct 1 ms 384 KB n = 8
11 Correct 0 ms 256 KB n = 8
12 Correct 0 ms 256 KB n = 8
13 Correct 0 ms 256 KB n = 8
14 Correct 0 ms 256 KB n = 8
15 Correct 0 ms 256 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 32
2 Correct 1 ms 384 KB n = 32
3 Correct 1 ms 384 KB n = 32
4 Correct 1 ms 384 KB n = 32
5 Correct 1 ms 384 KB n = 32
6 Correct 1 ms 384 KB n = 32
7 Correct 1 ms 384 KB n = 32
8 Correct 1 ms 384 KB n = 32
9 Correct 1 ms 384 KB n = 32
10 Correct 1 ms 384 KB n = 32
11 Correct 1 ms 384 KB n = 32
12 Correct 1 ms 384 KB n = 32
13 Correct 1 ms 384 KB n = 32
14 Correct 1 ms 384 KB n = 32
15 Correct 1 ms 384 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 32
2 Correct 1 ms 384 KB n = 32
3 Correct 1 ms 384 KB n = 32
4 Correct 1 ms 384 KB n = 32
5 Correct 1 ms 384 KB n = 32
6 Correct 1 ms 288 KB n = 32
7 Correct 1 ms 384 KB n = 32
8 Correct 1 ms 384 KB n = 32
9 Correct 1 ms 384 KB n = 32
10 Correct 1 ms 384 KB n = 32
11 Correct 1 ms 384 KB n = 32
12 Correct 1 ms 384 KB n = 32
13 Correct 1 ms 384 KB n = 32
14 Correct 1 ms 384 KB n = 32
15 Correct 1 ms 384 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB n = 128
2 Correct 2 ms 512 KB n = 128
3 Correct 2 ms 512 KB n = 128
4 Correct 2 ms 512 KB n = 128
5 Correct 2 ms 512 KB n = 128
6 Correct 2 ms 512 KB n = 128
7 Correct 2 ms 512 KB n = 128
8 Correct 2 ms 512 KB n = 128
9 Correct 2 ms 512 KB n = 128
10 Correct 2 ms 512 KB n = 128
11 Correct 2 ms 512 KB n = 128
12 Correct 2 ms 512 KB n = 128
13 Correct 2 ms 512 KB n = 128
14 Correct 2 ms 512 KB n = 128
15 Correct 2 ms 512 KB n = 128
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB n = 128
2 Correct 2 ms 512 KB n = 128
3 Correct 2 ms 512 KB n = 128
4 Correct 2 ms 512 KB n = 128
5 Correct 3 ms 512 KB n = 128
6 Correct 2 ms 512 KB n = 128
7 Correct 2 ms 512 KB n = 128
8 Correct 2 ms 512 KB n = 128
9 Correct 2 ms 512 KB n = 128
10 Correct 2 ms 512 KB n = 128
11 Correct 2 ms 512 KB n = 128
12 Correct 2 ms 512 KB n = 128
13 Correct 2 ms 512 KB n = 128
14 Correct 2 ms 512 KB n = 128
15 Correct 2 ms 512 KB n = 128