Submission #655601


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int MAXM = 1e6 + 5;
const int MAXD = 1e9 + 9;
const int LGN = 31; // 2 ^ 30 > 1e9

int n, m, d;
int a[ MAXN ];

int t[ LGN ][ MAXN ]; // terminal node when starting from node j, after playing 2 ^ i games

void solve(){
    for(int i = 1; i <= n; ++i)
        t[ 0 ][ i ] = i; // if there are no horizontal lines, it will go to itself
    for(int i = m - 1; i >= 0; --i) // lines are given from top to bottom
        swap<int>( t[ 0 ][ a[ i ] ], t[ 0 ][ a[ i ] + 1 ] );
    for(int i = 1; i < LGN; ++i)
        for(int j = 1; j <= n; ++j){
            int k = t[ i - 1 ][ j ];
            t[ i ][ j ] = t[ i - 1 ][ k ];
        }
    for(int i = 1; i <= n; ++i){
        int u = i;
        int td = d;
        for(int k = 0; k < LGN; ++k){
            if( td & 1 ) u = t[ k ][ u ];
            td >>= 1;
        }
        printf("%d\n", u);
    }
}

int main(){
    scanf("%d%d%d", &n, &m, &d);
    for(int i = 0; i < m; ++i)
        scanf("%d", &a[ i ]);
    solve();
    return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User Ow1
Language C++11 (GCC 4.8.1)
Score 100
Code Size 1102 Byte
Status AC
Exec Time 147 ms
Memory 13988 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &d);
                                ^
./Main.cpp:37:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[ i ]);
                             ^

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 144 ms 13944 KB
01_random01.txt AC 28 ms 1052 KB
01_random02.txt AC 29 ms 1064 KB
01_random03.txt AC 28 ms 1052 KB
01_random04.txt AC 30 ms 1400 KB
01_random05.txt AC 114 ms 13228 KB
01_random06.txt AC 135 ms 13732 KB
01_random07.txt AC 143 ms 13988 KB
02_i.txt AC 29 ms 1140 KB
02_p.txt AC 29 ms 1176 KB
02_random01.txt AC 29 ms 1060 KB
02_random02.txt AC 29 ms 1188 KB
02_random03.txt AC 29 ms 1184 KB
02_random04.txt AC 30 ms 1248 KB
02_random05.txt AC 33 ms 1268 KB
02_random06.txt AC 45 ms 1528 KB
02_random07.txt AC 62 ms 1908 KB
02_random08.txt AC 62 ms 1908 KB
02_rp01.txt AC 30 ms 1176 KB
02_rp02.txt AC 31 ms 1188 KB
02_rp03.txt AC 29 ms 1172 KB
02_rp04.txt AC 30 ms 1188 KB
02_rp05.txt AC 30 ms 1184 KB
03_i.txt AC 28 ms 1012 KB
03_random01.txt AC 28 ms 1140 KB
03_random02.txt AC 55 ms 1752 KB
03_random03.txt AC 52 ms 1624 KB
03_random04.txt AC 48 ms 1704 KB
03_random05.txt AC 32 ms 1140 KB
03_random06.txt AC 31 ms 1144 KB
03_random07.txt AC 34 ms 1268 KB
03_random08.txt AC 28 ms 1012 KB
03_random09.txt AC 35 ms 1312 KB
03_random10.txt AC 42 ms 1400 KB
03_random11.txt AC 54 ms 1700 KB
03_random12.txt AC 55 ms 1832 KB
03_random13.txt AC 50 ms 1688 KB
03_random14.txt AC 45 ms 1524 KB
03_random15.txt AC 35 ms 1260 KB
04_i.txt AC 147 ms 13936 KB
04_p1.txt AC 129 ms 13560 KB
04_p2.txt AC 105 ms 10916 KB
04_random01.txt AC 91 ms 8224 KB
04_random02.txt AC 69 ms 6564 KB
04_random03.txt AC 50 ms 2848 KB
04_random04.txt AC 64 ms 2848 KB
04_random05.txt AC 62 ms 3316 KB
04_random06.txt AC 88 ms 8688 KB
04_random07.txt AC 85 ms 6044 KB
04_random08.txt AC 77 ms 5364 KB
04_random09.txt AC 70 ms 3828 KB
04_random10.txt AC 84 ms 8612 KB
04_random11.txt AC 143 ms 13944 KB
04_random12.txt AC 146 ms 13924 KB
04_random13.txt AC 146 ms 13936 KB
04_rp01.txt AC 125 ms 13568 KB
04_rp02.txt AC 126 ms 13556 KB
04_rp03.txt AC 128 ms 13556 KB
04_rp04.txt AC 128 ms 13552 KB
04_rp05.txt AC 128 ms 13600 KB
04_rp06.txt AC 127 ms 13468 KB
04_rp07.txt AC 126 ms 13476 KB
04_rp08.txt AC 129 ms 13556 KB
04_rp09.txt AC 127 ms 13476 KB
04_rp10.txt AC 130 ms 13600 KB
sample_1.txt AC 30 ms 1052 KB
sample_2.txt AC 32 ms 1052 KB
sample_3.txt AC 32 ms 1008 KB