Submission #1013746

# Submission time Handle Problem Language Result Execution time Memory
1013746 2024-07-04T05:29:24 Z hotboy2703 Unscrambling a Messy Bug (IOI16_messy) C++17
49 / 100
1 ms 604 KB
#include <vector>

#include<bits/stdc++.h>
using namespace std;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))

#include "messy.h"
namespace BRUV{
    ll n;
    ll cnt_w,cnt_r;
    vector <ll> p;
    void add(ll l,ll r){
        if (l == r)return;
        string s;
        s.resize(n,'0');
        for (ll i = 0;i < l;i ++)s[i] = '1';
        for (ll i = r+1;i < n;i ++)s[i] = '1';
        ll mid = (l + r) >> 1;
        for (ll i = l;i <= mid;i ++){
            s[i] = '1';
            add_element(s);
            assert(++cnt_w <= 128*3);
            s[i] = '0';
        }
        add(l,mid);
        add(mid+1,r);
    }
    void solve(ll l,ll r,vector <ll> all_pos){
        if (l==r){p[all_pos[0]] = l;return;}
        string s;
        s.resize(n,'1');
        for (auto x:all_pos)s[x] = '0';
        vector <ll> L,R;
        ll mid = (l + r) >> 1;
        for (auto x:all_pos){
            s[x]='1';
            if (check_element(s))L.push_back(x);
            else R.push_back(x);
            assert(++cnt_r <= 128*3);
            s[x]='0';
        }
        solve(l,mid,L);
        solve(mid+1,r,R);
    }
}
std::vector<int> restore_permutation(int N, int w, int r) {
    using namespace BRUV;
    n=N;
    p.resize(n,-1);
    add(0,n-1);
    compile_set();
    vector <ll> sus(n);
    iota(sus.begin(),sus.end(),0);
    solve(0,n-1,sus);
    return p;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 8
2 Correct 0 ms 348 KB n = 8
3 Correct 0 ms 432 KB n = 8
4 Correct 0 ms 348 KB n = 8
5 Correct 0 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 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 348 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 0 ms 348 KB n = 8
15 Correct 0 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 0 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 0 ms 348 KB n = 32
6 Correct 0 ms 436 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 0 ms 348 KB n = 32
10 Correct 0 ms 348 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 0 ms 348 KB n = 32
15 Correct 0 ms 344 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 1 ms 348 KB n = 32
5 Correct 0 ms 348 KB n = 32
6 Correct 1 ms 348 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 0 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 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 1 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -