結果

問題 No.1013 〇マス進む
ユーザー bayashikobayashiko
提出日時 2021-02-11 18:51:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 2,672 bytes
コンパイル時間 2,669 ms
コンパイル使用メモリ 216,916 KB
実行使用メモリ 61,264 KB
最終ジャッジ日時 2023-09-25 08:33:34
合計ジャッジ時間 11,976 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 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,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 4 ms
5,096 KB
testcase_14 AC 39 ms
30,712 KB
testcase_15 AC 73 ms
48,392 KB
testcase_16 AC 63 ms
44,276 KB
testcase_17 AC 35 ms
27,272 KB
testcase_18 AC 47 ms
32,608 KB
testcase_19 AC 27 ms
20,684 KB
testcase_20 AC 86 ms
58,264 KB
testcase_21 AC 31 ms
25,272 KB
testcase_22 AC 47 ms
34,072 KB
testcase_23 AC 15 ms
13,128 KB
testcase_24 AC 89 ms
59,852 KB
testcase_25 AC 86 ms
58,744 KB
testcase_26 AC 16 ms
13,172 KB
testcase_27 AC 30 ms
24,212 KB
testcase_28 AC 16 ms
13,064 KB
testcase_29 AC 83 ms
56,936 KB
testcase_30 AC 29 ms
21,832 KB
testcase_31 AC 54 ms
38,888 KB
testcase_32 AC 38 ms
29,648 KB
testcase_33 AC 42 ms
29,704 KB
testcase_34 AC 78 ms
45,332 KB
testcase_35 AC 83 ms
43,016 KB
testcase_36 AC 6 ms
5,896 KB
testcase_37 AC 5 ms
5,640 KB
testcase_38 AC 82 ms
49,768 KB
testcase_39 AC 28 ms
18,160 KB
testcase_40 AC 98 ms
44,968 KB
testcase_41 AC 18 ms
13,540 KB
testcase_42 AC 43 ms
28,344 KB
testcase_43 AC 27 ms
19,356 KB
testcase_44 AC 44 ms
29,972 KB
testcase_45 AC 37 ms
26,804 KB
testcase_46 AC 20 ms
14,444 KB
testcase_47 AC 40 ms
28,504 KB
testcase_48 AC 50 ms
32,876 KB
testcase_49 AC 96 ms
45,092 KB
testcase_50 AC 63 ms
39,016 KB
testcase_51 AC 56 ms
34,940 KB
testcase_52 AC 11 ms
9,316 KB
testcase_53 AC 15 ms
12,280 KB
testcase_54 AC 58 ms
42,852 KB
testcase_55 AC 23 ms
14,864 KB
testcase_56 AC 96 ms
53,544 KB
testcase_57 AC 78 ms
37,364 KB
testcase_58 AC 137 ms
61,200 KB
testcase_59 AC 123 ms
61,064 KB
testcase_60 AC 103 ms
61,064 KB
testcase_61 AC 80 ms
61,172 KB
testcase_62 AC 74 ms
61,264 KB
testcase_63 AC 2 ms
4,376 KB
testcase_64 AC 2 ms
4,376 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]=i;
        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]];
    }
    doubling(vector<lint> in,vector<lint> in2, 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]=in2[i];
        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){
    int N,K;
    cin >> N >> K;
    vector<lint> P(N);
    rep(i,N) cin >> P[i];
    vector<lint> A(N);
    rep(i,N) A[i]=(i+P[i])%N;
    doubling D(A,P,35);
    rep(i,N) cout << D.dsum(i,K)+i+1 << endl;
}
0