답안 #611929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
611929 2022-07-29T08:54:01 Z hibiki 자동 인형 (IOI18_doll) C++11
85.5534 / 100
108 ms 14244 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

int pw2[32];
vector<int> nxt[100005], c, x, y;

int seat = -1;
int dfs(int val, int lv, int mlv, int head)
{
    if (lv == mlv)
    {
        if (nxt[head][val] == -1)
            return -seat;
        return nxt[head][val];
    }
    pair<int, int> ret;
    ret.f = dfs(val, lv + 1, mlv, head);
    ret.s = dfs(val + pw2[lv], lv + 1, mlv, head);
    if (lv)
    {
        if (ret.f == ret.s)
            return ret.f;
        x.pb(ret.f);
        y.pb(ret.s);
        return -sz(x);
    }
    else
    {
        x[seat - 1] = ret.f;
        y[seat - 1] = ret.s;
        return -seat;
    }
}

void create_circuit(int m, vector<int> a)
{
    int n = sz(a);
    pw2[0] = 1;
    for (int i = 1; i < 32; i++)
        pw2[i] = pw2[i - 1] * 2;

    nxt[0].pb(a[0]);
    for (int i = 0; i < n - 1; i++)
        nxt[a[i]].pb(a[i + 1]);
    nxt[a[n - 1]].pb(0);

    c.pb(nxt[0][0]);
    for (int i = 1; i <= m; i++)
    {
        if (nxt[i].empty())
        {
            c.pb(i);
            continue;
        }

        if (sz(nxt[i]) == 1)
        {
            c.pb(nxt[i][0]);
            continue;
        }

        int mlv = ceil(log2(sz(nxt[i])));
        int msz = pw2[mlv];

        int cur = 0;
        vector<int> temp;
        for (int j = 0; j < msz; j++)
        {
            int po = 0;
            for (int k = 0; k < mlv; k++)
            {
                if (j & pw2[k])
                    po += pw2[mlv - k - 1];
            }
            if (po < msz - sz(nxt[i]))
                temp.pb(-1);
            else
                temp.pb(nxt[i][cur++]);
        }
        nxt[i] = temp;

        x.pb(-1);
        y.pb(-1);
        seat = sz(x);
        c.pb(dfs(0, 0, mlv, i));
    }

    answer(c, x, y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 27 ms 6952 KB Output is correct
3 Correct 20 ms 6504 KB Output is correct
4 Correct 3 ms 2652 KB Output is correct
5 Correct 11 ms 4100 KB Output is correct
6 Correct 31 ms 8476 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 27 ms 6952 KB Output is correct
3 Correct 20 ms 6504 KB Output is correct
4 Correct 3 ms 2652 KB Output is correct
5 Correct 11 ms 4100 KB Output is correct
6 Correct 31 ms 8476 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 52 ms 9492 KB Output is correct
9 Correct 45 ms 9652 KB Output is correct
10 Correct 93 ms 11848 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 27 ms 6952 KB Output is correct
3 Correct 20 ms 6504 KB Output is correct
4 Correct 3 ms 2652 KB Output is correct
5 Correct 11 ms 4100 KB Output is correct
6 Correct 31 ms 8476 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 52 ms 9492 KB Output is correct
9 Correct 45 ms 9652 KB Output is correct
10 Correct 93 ms 11848 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 99 ms 13608 KB Output is correct
15 Correct 46 ms 8384 KB Output is correct
16 Correct 78 ms 10984 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 81 ms 12640 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2652 KB Output is correct
4 Correct 2 ms 2648 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 25 ms 5620 KB Output is correct
3 Correct 41 ms 6592 KB Output is correct
4 Correct 51 ms 7232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 25 ms 5620 KB Output is correct
3 Correct 41 ms 6592 KB Output is correct
4 Correct 51 ms 7232 KB Output is correct
5 Partially correct 88 ms 14244 KB Output is partially correct
6 Partially correct 108 ms 13872 KB Output is partially correct
7 Partially correct 88 ms 14028 KB Output is partially correct
8 Partially correct 86 ms 13048 KB Output is partially correct
9 Correct 52 ms 8076 KB Output is correct
10 Correct 84 ms 11612 KB Output is correct
11 Partially correct 96 ms 11772 KB Output is partially correct
12 Partially correct 64 ms 8940 KB Output is partially correct
13 Partially correct 61 ms 10228 KB Output is partially correct
14 Partially correct 58 ms 10316 KB Output is partially correct
15 Partially correct 61 ms 10240 KB Output is partially correct
16 Partially correct 3 ms 2900 KB Output is partially correct
17 Partially correct 49 ms 8308 KB Output is partially correct
18 Partially correct 49 ms 9220 KB Output is partially correct
19 Partially correct 52 ms 8432 KB Output is partially correct
20 Partially correct 68 ms 11164 KB Output is partially correct
21 Partially correct 73 ms 11168 KB Output is partially correct
22 Partially correct 69 ms 10788 KB Output is partially correct