AtCoder Grand Contest 006

Submission #958334

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int f[61][100000]={0};

int main()
{
    int n;
    scanf(" %d", &n);

    vector<int> x(n);
    rep(i,n) scanf(" %d", &x[i]);

    int m;
    ll k;
    scanf(" %d %lld", &m, &k);

    vector<int> a(m);
    rep(i,m)
    {
        scanf(" %d", &a[i]);
        --a[i];
    }

    rep(i,n-1) f[0][i]=i;
    rep(i,m) swap(f[0][a[i]],f[0][a[i]-1]);
    for(int i=1; i<=60; ++i)rep(j,n-1) f[i][j]=f[i-1][f[i-1][j]];

    vector<ll> d(n-1);
    rep(i,n-1) d[i]=x[i+1]-x[i];

    vector<int> pos(n-1);
    rep(i,n-1) pos[i]=i;

    for(int i=60; i>=0; --i)
    {
        if(k-(1LL<<i)>=0)
        {
            vector<int> newpos(n-1);
            rep(j,n-1) newpos[j]=f[i][pos[j]];

            k-=(1LL<<i);
            pos=newpos;
        }
    }

    vector<ll> E(n,0);
    E[0]=x[0];
    rep(i,n-1) E[i+1]=E[i]+d[pos[i]];

    rep(i,n) printf("%lld\n", E[i]);
    return 0;
}

Submission

Task問題 C - Rabbit Exercise
User nameユーザ名 imulan
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 800
Source lengthソースコード長 1227 Byte
File nameファイル名
Exec time実行時間 74 ms
Memory usageメモリ使用量 28152 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d", &n);
^
./Main.cpp:20:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n) scanf(" %d", &x[i]);
^
./Main.cpp:24:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d %lld", &m, &k);
^
./Main.cpp:29:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d", &a[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
All 800 / 800 0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt,1_18.txt,1_19.txt,1_20.txt,1_21.txt,1_22.txt,1_23.txt,1_24.txt,1_25.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_00.txt AC 3 ms 512 KB
0_01.txt AC 3 ms 512 KB
0_02.txt AC 3 ms 512 KB
1_00.txt AC 3 ms 512 KB
1_01.txt AC 3 ms 512 KB
1_02.txt AC 65 ms 27768 KB
1_03.txt AC 74 ms 28152 KB
1_04.txt AC 54 ms 19448 KB
1_05.txt AC 5 ms 768 KB
1_06.txt AC 10 ms 768 KB
1_07.txt AC 7 ms 896 KB
1_08.txt AC 9 ms 1024 KB
1_09.txt AC 9 ms 1024 KB
1_10.txt AC 5 ms 640 KB
1_11.txt AC 7 ms 768 KB
1_12.txt AC 3 ms 512 KB
1_13.txt AC 11 ms 896 KB
1_14.txt AC 7 ms 768 KB
1_15.txt AC 16 ms 3072 KB
1_16.txt AC 7 ms 1920 KB
1_17.txt AC 38 ms 12252 KB
1_18.txt AC 45 ms 15280 KB
1_19.txt AC 57 ms 20204 KB
1_20.txt AC 25 ms 6400 KB
1_21.txt AC 28 ms 8448 KB
1_22.txt AC 57 ms 20204 KB
1_23.txt AC 59 ms 23860 KB
1_24.txt AC 43 ms 17928 KB
1_25.txt AC 67 ms 27384 KB