AtCoder Beginner Contest 013

Submission #6906362

Source codeソースコード

#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 a[m];
    rep(i, m) cin >> a[i];
    
    int nxt[40][n + 1];
    rep(i, n) {
        int now = i + 1;
        rep(k, m) {
            if (now == a[k]) now = a[k] + 1;
            else if (now == a[k] + 1) now = a[k];
            
        }
        nxt[0][i + 1] = now; // 2^0 = 1回で
    }
    
    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

Task問題 D - 阿弥陀
User nameユーザ名 tac_
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 40
Source lengthソースコード長 1994 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 0 / 10 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 20 / 20 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 20 / 20 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 0 / 50 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01_i.txt TLE
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 36 ms 768 KB
01_random05.txt AC 3070 ms 16640 KB
01_random06.txt TLE
01_random07.txt TLE
02_i.txt AC 5 ms 384 KB
02_p.txt AC 4 ms 384 KB
02_random01.txt AC 1 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 6 ms 384 KB
02_random04.txt AC 3 ms 384 KB
02_random05.txt AC 24 ms 512 KB
02_random06.txt AC 108 ms 768 KB
02_random07.txt AC 212 ms 1152 KB
02_random08.txt AC 212 ms 1152 KB
02_rp01.txt AC 4 ms 384 KB
02_rp02.txt AC 4 ms 384 KB
02_rp03.txt AC 4 ms 384 KB
02_rp04.txt AC 4 ms 384 KB
02_rp05.txt AC 4 ms 384 KB
03_i.txt AC 1 ms 256 KB
03_random01.txt AC 2 ms 384 KB
03_random02.txt AC 12 ms 1024 KB
03_random03.txt AC 10 ms 896 KB
03_random04.txt AC 11 ms 896 KB
03_random05.txt AC 3 ms 384 KB
03_random06.txt AC 3 ms 384 KB
03_random07.txt AC 4 ms 384 KB
03_random08.txt AC 1 ms 256 KB
03_random09.txt AC 5 ms 512 KB
03_random10.txt AC 9 ms 640 KB
03_random11.txt AC 14 ms 1024 KB
03_random12.txt AC 15 ms 1024 KB
03_random13.txt AC 12 ms 896 KB
03_random14.txt AC 9 ms 768 KB
03_random15.txt AC 4 ms 384 KB
04_i.txt TLE
04_p1.txt TLE
04_p2.txt TLE
04_random01.txt TLE
04_random02.txt AC 2039 ms 7552 KB
04_random03.txt AC 1075 ms 2304 KB
04_random04.txt AC 1572 ms 2304 KB
04_random05.txt AC 2056 ms 3072 KB
04_random06.txt TLE
04_random07.txt TLE
04_random08.txt TLE
04_random09.txt AC 3319 ms 3712 KB
04_random10.txt AC 3502 ms 10368 KB
04_random11.txt TLE
04_random12.txt TLE
04_random13.txt TLE
04_rp01.txt TLE
04_rp02.txt TLE
04_rp03.txt TLE
04_rp04.txt TLE
04_rp05.txt TLE
04_rp06.txt TLE
04_rp07.txt TLE
04_rp08.txt TLE
04_rp09.txt TLE
04_rp10.txt TLE
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB