Submission #796799

# Submission time Handle Problem Language Result Execution time Memory
796799 2023-07-28T18:28:15 Z BT21tata Unscrambling a Messy Bug (IOI16_messy) C++17
100 / 100
2 ms 508 KB
#include<bits/stdc++.h>
#include "messy.h"
#define pb push_back
using namespace std;

int n;
vector<int>ans;

void build(int l, int r)
{
    if(r-l==0) return;
    string s;
    for(int i=0; i<n; i++) s+='0';
    for(int i=l; i<=r; i++) s[i]='1';

    int mid=(l+r)>>1;
    for(int i=l; i<=mid; i++)
    {
        s[i]='0';
        add_element(s);
        // cout<<"add_element "<<s<<endl;
        s[i]='1';
    }
    build(l, mid);
    build(mid+1, r);
}

void calc(vector<int>can, int cur)
{
    if(can.size()==1)
    {
        ans[can[0]]=cur;
        return;
    }
    vector<int>v1, v2;
    string s;
    for(int i=0; i<n; i++) s+='0';
    for(int u : can) s[u]='1';
    for(int u : can)
    {
        s[u]='0';
        if(check_element(s)) v1.pb(u);
        else v2.pb(u);
        s[u]='1';
    }

    calc(v1, cur);
    calc(v2, cur+v1.size());
}

vector<int> restore_permutation(int N, int w, int r)
{
    n=N; ans.resize(n);
    build(0, n-1);
    compile_set();
    vector<int>can;
    for(int i=0; i<n; i++)
        can.pb(i);
    calc(can, 0);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 8
2 Correct 0 ms 212 KB n = 8
3 Correct 0 ms 300 KB n = 8
4 Correct 0 ms 304 KB n = 8
5 Correct 0 ms 212 KB n = 8
6 Correct 0 ms 212 KB n = 8
7 Correct 0 ms 212 KB n = 8
8 Correct 0 ms 212 KB n = 8
9 Correct 1 ms 212 KB n = 8
10 Correct 1 ms 212 KB n = 8
11 Correct 0 ms 212 KB n = 8
12 Correct 0 ms 212 KB n = 8
13 Correct 1 ms 212 KB n = 8
14 Correct 1 ms 212 KB n = 8
15 Correct 0 ms 212 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 32
2 Correct 1 ms 212 KB n = 32
3 Correct 0 ms 300 KB n = 32
4 Correct 1 ms 212 KB n = 32
5 Correct 1 ms 296 KB n = 32
6 Correct 1 ms 296 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 296 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
# Verdict Execution time Memory Grader output
1 Correct 0 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 212 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 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 0 ms 212 KB n = 32
13 Correct 1 ms 212 KB n = 32
14 Correct 1 ms 300 KB n = 32
15 Correct 0 ms 212 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB n = 128
2 Correct 1 ms 424 KB n = 128
3 Correct 1 ms 376 KB n = 128
4 Correct 1 ms 468 KB n = 128
5 Correct 1 ms 468 KB n = 128
6 Correct 1 ms 468 KB n = 128
7 Correct 2 ms 428 KB n = 128
8 Correct 1 ms 428 KB n = 128
9 Correct 1 ms 468 KB n = 128
10 Correct 1 ms 468 KB n = 128
11 Correct 1 ms 508 KB n = 128
12 Correct 1 ms 424 KB n = 128
13 Correct 1 ms 468 KB n = 128
14 Correct 1 ms 468 KB n = 128
15 Correct 1 ms 468 KB n = 128
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB n = 128
2 Correct 1 ms 468 KB n = 128
3 Correct 1 ms 468 KB n = 128
4 Correct 1 ms 428 KB n = 128
5 Correct 1 ms 468 KB n = 128
6 Correct 1 ms 428 KB n = 128
7 Correct 1 ms 468 KB n = 128
8 Correct 1 ms 476 KB n = 128
9 Correct 1 ms 468 KB n = 128
10 Correct 1 ms 468 KB n = 128
11 Correct 1 ms 468 KB n = 128
12 Correct 1 ms 468 KB n = 128
13 Correct 1 ms 424 KB n = 128
14 Correct 1 ms 468 KB n = 128
15 Correct 1 ms 468 KB n = 128