Submission #973472

# Submission time Handle Problem Language Result Execution time Memory
973472 2024-05-02T04:45:08 Z vjudge1 Unscrambling a Messy Bug (IOI16_messy) C
100 / 100
4 ms 2392 KB
#include "messy_c.h"
#define N 128

void solve_add(int n, int w, int r, int x, int y)
{
    if (x == y) return;

    char ask[N+1]={0};

    for(int i=0;i<n;++i)ask[i]='0' + (i<x||i>y);

    int m = x+(y-x)/2;
    for(int i=x;i<=m;++i)
    {
        ask[i]='1';
        add_element(ask);
        ask[i]='0';
    }
    solve_add(n, w, r, x, m);
    solve_add(n, w, r, m+1, y);
}

void solve_restore(int n, int w, int r, int x, int y, int *mapped, int *result)
{
    if (x == y) { result[x] = mapped[0]; return; }

    char ask[N+1]={0};

    for(int i=0;i<n;++i)ask[i]='1';
    for(int i=x;i<=y;++i)ask[mapped[i-x]]='0';

    int nmapped[N],no=0,mmapped[N],mo=0;
    int m=x+(y-x)/2;

    for(int i=x;i<=y;++i)
    {
        ask[mapped[i-x]]='1';
        if(check_element(ask))
            nmapped[no++]=mapped[i-x];
        else
            mmapped[mo++]=mapped[i-x];
        ask[mapped[i-x]]='0';
    }
    solve_restore(n, w, r, x, m, nmapped, result);
    solve_restore(n, w, r, m+1, y, mmapped, result);
}

void restore_permutation(int n, int w, int r, int* result)
{
    solve_add(n, w, r, 0, n-1);
    compile_set();

    int mapped[N], iresult[N];
    for (int i = 0; i < n; ++i) mapped[i] = i;
    solve_restore(n, w, r, 0, n-1, mapped, iresult);
    for (int i=0;i<n;++i)result[iresult[i]]=i;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 8
2 Correct 0 ms 348 KB n = 8
3 Correct 0 ms 348 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 344 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 1 ms 344 KB n = 32
6 Correct 1 ms 344 KB n = 32
7 Correct 1 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 1 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 1 ms 348 KB n = 32
4 Correct 1 ms 500 KB n = 32
5 Correct 0 ms 348 KB n = 32
6 Correct 0 ms 344 KB n = 32
7 Correct 1 ms 348 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 1 ms 344 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 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2140 KB n = 128
2 Correct 3 ms 2140 KB n = 128
3 Correct 2 ms 2140 KB n = 128
4 Correct 2 ms 2140 KB n = 128
5 Correct 2 ms 2140 KB n = 128
6 Correct 2 ms 2392 KB n = 128
7 Correct 3 ms 2140 KB n = 128
8 Correct 2 ms 2140 KB n = 128
9 Correct 2 ms 2140 KB n = 128
10 Correct 2 ms 2352 KB n = 128
11 Correct 2 ms 2140 KB n = 128
12 Correct 3 ms 2140 KB n = 128
13 Correct 2 ms 2140 KB n = 128
14 Correct 2 ms 2144 KB n = 128
15 Correct 2 ms 2148 KB n = 128
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2152 KB n = 128
2 Correct 2 ms 2356 KB n = 128
3 Correct 3 ms 2140 KB n = 128
4 Correct 2 ms 2140 KB n = 128
5 Correct 2 ms 2148 KB n = 128
6 Correct 2 ms 2152 KB n = 128
7 Correct 4 ms 2152 KB n = 128
8 Correct 2 ms 2140 KB n = 128
9 Correct 2 ms 2140 KB n = 128
10 Correct 2 ms 2140 KB n = 128
11 Correct 2 ms 2140 KB n = 128
12 Correct 2 ms 2140 KB n = 128
13 Correct 2 ms 2140 KB n = 128
14 Correct 2 ms 2140 KB n = 128
15 Correct 2 ms 2140 KB n = 128