結果

問題 No.1013 〇マス進む
ユーザー DAyamaCTF
提出日時 2020-03-23 14:41:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,142 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 161,676 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-12-26 05:56:09
合計ジャッジ時間 10,640 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

P operator*(const P& a,const P& b){
	return P(a.fi+b.fi,b.se);
}

ll N,K;
vector<ll> A;
P f[31][100010];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>N>>K;
  A.resize(N);
  rep(i,N)cin>>A[i];
  rep(i,N){
  	if(i+A[i]>=N) f[0][i]=P(1,(i+A[i])%N);
  	else f[0][i]=P(0,(i+A[i])%N);
  }

  rep(k,30){
  	rep(i,N){
  		f[k+1][i]=f[k][i]*f[k][f[k][i].se];
  	}
  }

  K--;
  rep(i,N){
  	P res=f[0][i];
  	rep(k,30){
  		if((K>>k)&1){
  			res=res*f[k][res.se];
  		}
  	}
  	cout<<res.fi*N+res.se+1<<endl;
  }

  return 0;
}
0