結果

問題 No.1013 〇マス進む
ユーザー bayashikobayashiko
提出日時 2021-02-11 16:51:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 2,312 bytes
コンパイル時間 2,682 ms
コンパイル使用メモリ 217,564 KB
実行使用メモリ 68,260 KB
最終ジャッジ日時 2023-09-25 06:30:39
合計ジャッジ時間 12,466 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
5,396 KB
testcase_14 AC 43 ms
34,128 KB
testcase_15 AC 78 ms
53,464 KB
testcase_16 AC 71 ms
49,128 KB
testcase_17 AC 40 ms
30,228 KB
testcase_18 AC 51 ms
36,244 KB
testcase_19 AC 30 ms
23,264 KB
testcase_20 AC 94 ms
64,948 KB
testcase_21 AC 34 ms
27,852 KB
testcase_22 AC 51 ms
37,624 KB
testcase_23 AC 16 ms
14,344 KB
testcase_24 AC 94 ms
66,608 KB
testcase_25 AC 90 ms
65,200 KB
testcase_26 AC 16 ms
14,376 KB
testcase_27 AC 31 ms
26,420 KB
testcase_28 AC 16 ms
14,404 KB
testcase_29 AC 88 ms
63,492 KB
testcase_30 AC 31 ms
23,784 KB
testcase_31 AC 58 ms
43,172 KB
testcase_32 AC 41 ms
32,760 KB
testcase_33 AC 47 ms
32,756 KB
testcase_34 AC 83 ms
50,552 KB
testcase_35 AC 87 ms
47,876 KB
testcase_36 AC 6 ms
6,264 KB
testcase_37 AC 6 ms
6,060 KB
testcase_38 AC 87 ms
55,512 KB
testcase_39 AC 29 ms
19,824 KB
testcase_40 AC 102 ms
50,356 KB
testcase_41 AC 19 ms
14,544 KB
testcase_42 AC 45 ms
31,496 KB
testcase_43 AC 28 ms
21,192 KB
testcase_44 AC 47 ms
33,076 KB
testcase_45 AC 42 ms
29,688 KB
testcase_46 AC 21 ms
15,716 KB
testcase_47 AC 42 ms
31,492 KB
testcase_48 AC 52 ms
36,548 KB
testcase_49 AC 99 ms
50,296 KB
testcase_50 AC 66 ms
43,120 KB
testcase_51 AC 60 ms
39,012 KB
testcase_52 AC 11 ms
10,108 KB
testcase_53 AC 15 ms
13,196 KB
testcase_54 AC 64 ms
47,596 KB
testcase_55 AC 24 ms
16,300 KB
testcase_56 AC 103 ms
59,480 KB
testcase_57 AC 83 ms
41,468 KB
testcase_58 AC 140 ms
68,252 KB
testcase_59 AC 124 ms
68,192 KB
testcase_60 AC 112 ms
68,260 KB
testcase_61 AC 90 ms
68,248 KB
testcase_62 AC 86 ms
68,196 KB
testcase_63 AC 2 ms
4,376 KB
testcase_64 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
//#include<atcoder/all>
//using namespace atcoder;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define flc(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define vec vector<lint>
#define nep(x) next_permutation(all(x))
typedef long long lint;
typedef __int128_t llint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=3e5+5;
//vector<int> bucket[MAX_N/1000];
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;

struct doubling{
    vector<vector<lint>> to,sum;
    doubling(vector<lint> in,int log){
        to.resize(log);
        rep(i,log) to[i].resize(in.size());
        rep(i,in.size()) to[0][i]=in[i];
        for(int i=1;i<log;i++) rep(j,in.size()) to[i][j]=to[i-1][to[i-1][j]];
        sum.resize(log);
        rep(i,log) sum[i].resize(in.size());
        rep(i,in.size()){
            sum[0][i]=(in[i]-i);
            if(sum[0][i]<=0) sum[0][i]+=to[0].size()-1;
        }
        for(int i=1;i<log;i++) rep(j,in.size()) sum[i][j]=sum[i-1][j]+sum[i-1][to[i-1][j]];
    }
    lint dest(lint now,lint k){//nowのk個先
        rep(i,to.size()){
            if(k&(1LL<<i)) now=to[i][now];
        }
        return now;
    }
    lint dsum(lint now,lint k){//Σ[i=0..k-1]
        lint res=0;
        rep(i,to.size()){
            if(k&(1LL<<i)) res+=sum[i][now],now=to[i][now];
        }
        return res;
    }
};

int main(void){
    lint N,K;
    cin >> N >> K;
    vector<lint> P(N);
    rep(i,N) cin >> P[i];
    vector<lint> A(N+1);
    rep(i,N) A[i+1]=(i+P[i])%N+1;
    doubling D(A,40);
    rep(i,N) cout << D.dsum(i+1,K)+i+1 << endl; 
}
0