Submission #6907038


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, m, d;
    cin >> n >> m >> d;
    

    int nxt[40][n + 1];
    map<int, int> mp;
    rep(i, n + 1) mp[i] = i;
    rep(i, m) {
        int a;
        cin >> a;
        // out(mp[a] << " " << mp[a + 1]);
        swap(mp[a], mp[a + 1]);
        
        // rep(_, n + 1) cout << mp[_] << " "; cout << endl;
    }
    
    // rep(i, n + 1) cout << nxt[0][i] << " "; cout << endl;
    rep3(i, 1, n + 1) nxt[0][mp[i]] = i;
    rep3(i, 1, 40) {
        rep3(j, 1, n + 1) {
            nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
        }
    }
    
    rep(i, n) {
        int now = i + 1;
        
        int j = d;
        int k = 0;
        while (j) {
            if (j % 2 != 0) {
                now = nxt[k][now];
            }
            j /= 2;
            k++;
        }
        out(now);
    }
}


Submission Info

Submission Time
Task D - 阿弥陀
User tac_
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2072 Byte
Status AC
Exec Time 297 ms
Memory 21120 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 287 ms 21120 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 8 ms 896 KB
01_random05.txt AC 205 ms 21120 KB
01_random06.txt AC 261 ms 21120 KB
01_random07.txt AC 289 ms 21120 KB
02_i.txt AC 3 ms 512 KB
02_p.txt AC 3 ms 512 KB
02_random01.txt AC 1 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 3 ms 384 KB
02_random04.txt AC 3 ms 512 KB
02_random05.txt AC 6 ms 512 KB
02_random06.txt AC 20 ms 512 KB
02_random07.txt AC 38 ms 512 KB
02_random08.txt AC 38 ms 512 KB
02_rp01.txt AC 3 ms 512 KB
02_rp02.txt AC 3 ms 512 KB
02_rp03.txt AC 3 ms 512 KB
02_rp04.txt AC 3 ms 512 KB
02_rp05.txt AC 3 ms 512 KB
03_i.txt AC 1 ms 256 KB
03_random01.txt AC 2 ms 256 KB
03_random02.txt AC 13 ms 256 KB
03_random03.txt AC 11 ms 256 KB
03_random04.txt AC 12 ms 384 KB
03_random05.txt AC 3 ms 256 KB
03_random06.txt AC 3 ms 256 KB
03_random07.txt AC 4 ms 256 KB
03_random08.txt AC 1 ms 256 KB
03_random09.txt AC 6 ms 256 KB
03_random10.txt AC 9 ms 256 KB
03_random11.txt AC 15 ms 256 KB
03_random12.txt AC 16 ms 256 KB
03_random13.txt AC 12 ms 256 KB
03_random14.txt AC 10 ms 256 KB
03_random15.txt AC 5 ms 256 KB
04_i.txt AC 296 ms 21120 KB
04_p1.txt AC 217 ms 21120 KB
04_p2.txt AC 173 ms 16768 KB
04_random01.txt AC 149 ms 11776 KB
04_random02.txt AC 101 ms 9472 KB
04_random03.txt AC 49 ms 2432 KB
04_random04.txt AC 68 ms 2048 KB
04_random05.txt AC 73 ms 3072 KB
04_random06.txt AC 149 ms 12800 KB
04_random07.txt AC 142 ms 7552 KB
04_random08.txt AC 119 ms 6528 KB
04_random09.txt AC 97 ms 3840 KB
04_random10.txt AC 138 ms 12928 KB
04_random11.txt AC 297 ms 21120 KB
04_random12.txt AC 297 ms 21120 KB
04_random13.txt AC 293 ms 21120 KB
04_rp01.txt AC 212 ms 21120 KB
04_rp02.txt AC 213 ms 21120 KB
04_rp03.txt AC 220 ms 21120 KB
04_rp04.txt AC 218 ms 21120 KB
04_rp05.txt AC 220 ms 21120 KB
04_rp06.txt AC 217 ms 21120 KB
04_rp07.txt AC 214 ms 21120 KB
04_rp08.txt AC 215 ms 21120 KB
04_rp09.txt AC 214 ms 21120 KB
04_rp10.txt AC 218 ms 21120 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