Submission #1958959


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

const int MAX_N = 100000;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N, M, D;

    gc(N);
    gc(M);
    gc(D);

    vector<int> src(N, 0);
    vector<int> dst(N, 0);

    for (int i = 0; i < N; i++)
        src[i] = dst[i] = i;

    for (int i = 0; i < M; i++)
    {
        int A;
        gc(A);

        swap(dst[A - 1], dst[A]);
    }

    int log2D = (int)log2(D);

    vector< vector<int> > dbl(log2D + 1, vector<int>());

    copy(dst.begin(), dst.end(), back_inserter(dbl[0]));

    for (int i = 1; i < log2D + 1; i++)
    {
        vector<int> tmp;

        copy(dst.begin(), dst.end(), back_inserter(tmp));

        for (int j = 0; j < N; j++)
            dst[j] = tmp[dst[j]];

        copy(dst.begin(), dst.end(), back_inserter(dbl[i]));
    }

    int i = 0;
    while (D)
    {
        // 最下位ビット取り出し
        if (D & 1)
            for (int j = 0; j < N; j++)
                src[j] = dbl[i][src[j]];

        // 1桁右シフト
        D >>= 1;

        i++;
    }

    vector<int> res(N, 0);
    for (int i = 0; i < N; i++)
    {
        res[src[i]] = i + 1;
    }

    for (int i = 0; i < N; i++) printf("%d\n", res[i]);
    return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User ShinjiSHIBATA
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1708 Byte
Status AC
Exec Time 38 ms
Memory 14320 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 20 / 20 50 / 50
Status
AC × 9
AC × 18
AC × 18
AC × 29
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 15 ms 2552 KB
01_random01.txt AC 1 ms 256 KB
01_random02.txt AC 1 ms 256 KB
01_random03.txt AC 1 ms 256 KB
01_random04.txt AC 2 ms 256 KB
01_random05.txt AC 12 ms 2552 KB
01_random06.txt AC 14 ms 2552 KB
01_random07.txt AC 15 ms 2552 KB
02_i.txt AC 1 ms 256 KB
02_p.txt AC 1 ms 256 KB
02_random01.txt AC 1 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 1 ms 256 KB
02_random04.txt AC 1 ms 256 KB
02_random05.txt AC 2 ms 256 KB
02_random06.txt AC 3 ms 256 KB
02_random07.txt AC 4 ms 256 KB
02_random08.txt AC 4 ms 256 KB
02_rp01.txt AC 2 ms 384 KB
02_rp02.txt AC 1 ms 256 KB
02_rp03.txt AC 1 ms 256 KB
02_rp04.txt AC 1 ms 256 KB
02_rp05.txt AC 1 ms 256 KB
03_i.txt AC 1 ms 256 KB
03_random01.txt AC 1 ms 256 KB
03_random02.txt AC 2 ms 256 KB
03_random03.txt AC 2 ms 256 KB
03_random04.txt AC 2 ms 256 KB
03_random05.txt AC 1 ms 256 KB
03_random06.txt AC 1 ms 256 KB
03_random07.txt AC 2 ms 256 KB
03_random08.txt AC 1 ms 256 KB
03_random09.txt AC 2 ms 256 KB
03_random10.txt AC 2 ms 256 KB
03_random11.txt AC 2 ms 256 KB
03_random12.txt AC 2 ms 256 KB
03_random13.txt AC 2 ms 256 KB
03_random14.txt AC 2 ms 256 KB
03_random15.txt AC 2 ms 256 KB
04_i.txt AC 38 ms 14192 KB
04_p1.txt AC 35 ms 13808 KB
04_p2.txt AC 28 ms 10944 KB
04_random01.txt AC 22 ms 7972 KB
04_random02.txt AC 17 ms 6604 KB
04_random03.txt AC 6 ms 1792 KB
04_random04.txt AC 7 ms 1536 KB
04_random05.txt AC 9 ms 2176 KB
04_random06.txt AC 23 ms 8592 KB
04_random07.txt AC 17 ms 5360 KB
04_random08.txt AC 14 ms 4104 KB
04_random09.txt AC 11 ms 2620 KB
04_random10.txt AC 23 ms 8716 KB
04_random11.txt AC 37 ms 13424 KB
04_random12.txt AC 38 ms 13808 KB
04_random13.txt AC 35 ms 12656 KB
04_rp01.txt AC 35 ms 13424 KB
04_rp02.txt AC 35 ms 13424 KB
04_rp03.txt AC 36 ms 14192 KB
04_rp04.txt AC 34 ms 13424 KB
04_rp05.txt AC 34 ms 13040 KB
04_rp06.txt AC 34 ms 13040 KB
04_rp07.txt AC 34 ms 13040 KB
04_rp08.txt AC 35 ms 13424 KB
04_rp09.txt AC 36 ms 14320 KB
04_rp10.txt AC 37 ms 14192 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB