結果
問題 |
No.1013 〇マス進む
|
ユーザー |
👑 ![]() |
提出日時 | 2020-12-11 00:39:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 181 ms / 2,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 1,920 ms |
コンパイル使用メモリ | 196,548 KB |
最終ジャッジ日時 | 2025-01-16 21:47:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 62 |
ソースコード
#include<bits/stdc++.h> using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0;i<(n);i++) int N,K; struct F{ struct Node{ int i,cy; }; vector<Node> V; F(){ V.resize(N); rep(i,N) V[i]={i,0}; } F operator*(const F& r)const{ F res; rep(i,N){ res.V[i].i=r.V[V[i].i].i; res.V[i].cy=V[i].cy+r.V[V[i].i].cy; } return res; } F pow(int i){ if(i==0) return F(); F res=pow(i/2); res=res*res; if(i%2==1) res=res* *this; return res; } }; int main(){ cin>>N>>K; F G; for(auto& q: G.V){ int a; cin>>a; q.i+=a; if(q.i>=N){ q.i-=N; q.cy++; } } G=G.pow(K); for(auto& q: G.V) cout<<(LL(q.cy)*N+q.i+1)<<endl; return 0; }