結果

問題 No.1013 〇マス進む
ユーザー okok
提出日時 2020-03-20 22:32:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 90,356 KB
実行使用メモリ 58,008 KB
最終ジャッジ日時 2024-05-08 22:47:41
合計ジャッジ時間 7,409 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 53 ms
29,512 KB
testcase_15 AC 95 ms
45,700 KB
testcase_16 AC 82 ms
42,092 KB
testcase_17 AC 47 ms
26,044 KB
testcase_18 AC 62 ms
31,248 KB
testcase_19 AC 35 ms
19,892 KB
testcase_20 AC 111 ms
55,192 KB
testcase_21 AC 43 ms
24,168 KB
testcase_22 AC 61 ms
32,200 KB
testcase_23 AC 20 ms
12,540 KB
testcase_24 AC 118 ms
57,060 KB
testcase_25 AC 114 ms
55,608 KB
testcase_26 AC 22 ms
12,668 KB
testcase_27 AC 40 ms
22,968 KB
testcase_28 AC 21 ms
12,664 KB
testcase_29 AC 113 ms
54,120 KB
testcase_30 AC 39 ms
20,696 KB
testcase_31 AC 75 ms
36,880 KB
testcase_32 AC 51 ms
28,192 KB
testcase_33 AC 58 ms
28,188 KB
testcase_34 AC 98 ms
43,292 KB
testcase_35 AC 105 ms
40,892 KB
testcase_36 AC 8 ms
5,888 KB
testcase_37 AC 7 ms
5,632 KB
testcase_38 AC 112 ms
47,304 KB
testcase_39 AC 37 ms
17,480 KB
testcase_40 AC 115 ms
42,896 KB
testcase_41 AC 24 ms
12,928 KB
testcase_42 AC 59 ms
27,112 KB
testcase_43 AC 38 ms
18,552 KB
testcase_44 AC 59 ms
28,456 KB
testcase_45 AC 51 ms
25,380 KB
testcase_46 AC 26 ms
13,824 KB
testcase_47 AC 51 ms
27,244 KB
testcase_48 AC 65 ms
31,396 KB
testcase_49 AC 112 ms
42,764 KB
testcase_50 AC 86 ms
37,008 KB
testcase_51 AC 74 ms
33,396 KB
testcase_52 AC 14 ms
9,088 KB
testcase_53 AC 21 ms
11,776 KB
testcase_54 AC 83 ms
40,748 KB
testcase_55 AC 29 ms
14,336 KB
testcase_56 AC 124 ms
50,652 KB
testcase_57 AC 95 ms
35,672 KB
testcase_58 AC 164 ms
57,956 KB
testcase_59 AC 150 ms
58,008 KB
testcase_60 AC 134 ms
57,876 KB
testcase_61 AC 116 ms
58,004 KB
testcase_62 AC 104 ms
57,876 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K;
	vector<int> P;
	vector<vector<int>> db;
	vector<vector<int>> in;
	
	cin>>N>>K;
	
	P.resize(N);
	db.resize(34,vector<int>(N));
	in.resize(34,vector<int>(N));
	
	for(int i = 0; i < N; i++){
		cin>>P[i];
		db[0][i] = P[i];
		in[0][i] = (P[i] + i) % N;
	}
	
	for(int i = 1; i < db.size(); i++){
		for(int j = 0; j < N; j++){
			db[i][j] = db[i-1][in[i-1][j]] + db[i-1][j];
			in[i][j] = (db[i][j] + j) % N;
		}
	}			
	
	for(int i = 0; i < N; i++){
		int sum = i+1, now = i;
		
		for(int i = 0; i < db.size(); i++){
			if((1ll<<i)&K) {
				int temp = db[i][now%N];
				now = in[i][now];
				sum += temp;
				// now = temp % N;
			}
		}
		
		cout<<sum<<endl;
	}
	
	return 0;
}
0