結果

問題 No.1013 〇マス進む
ユーザー okok
提出日時 2020-03-20 22:32:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 88,260 KB
実行使用メモリ 57,888 KB
最終ジャッジ日時 2023-08-21 17:18:36
合計ジャッジ時間 7,779 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 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,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
4,852 KB
testcase_14 AC 53 ms
29,216 KB
testcase_15 AC 93 ms
45,532 KB
testcase_16 AC 81 ms
41,960 KB
testcase_17 AC 47 ms
25,948 KB
testcase_18 AC 60 ms
31,268 KB
testcase_19 AC 35 ms
19,708 KB
testcase_20 AC 113 ms
55,120 KB
testcase_21 AC 41 ms
23,924 KB
testcase_22 AC 64 ms
31,944 KB
testcase_23 AC 19 ms
12,468 KB
testcase_24 AC 115 ms
56,656 KB
testcase_25 AC 111 ms
55,836 KB
testcase_26 AC 20 ms
12,380 KB
testcase_27 AC 39 ms
22,968 KB
testcase_28 AC 20 ms
12,468 KB
testcase_29 AC 105 ms
54,040 KB
testcase_30 AC 38 ms
20,652 KB
testcase_31 AC 73 ms
36,772 KB
testcase_32 AC 50 ms
28,136 KB
testcase_33 AC 56 ms
28,232 KB
testcase_34 AC 98 ms
42,952 KB
testcase_35 AC 102 ms
40,752 KB
testcase_36 AC 7 ms
5,632 KB
testcase_37 AC 7 ms
5,856 KB
testcase_38 AC 105 ms
47,236 KB
testcase_39 AC 35 ms
17,136 KB
testcase_40 AC 115 ms
42,896 KB
testcase_41 AC 23 ms
12,848 KB
testcase_42 AC 56 ms
27,176 KB
testcase_43 AC 36 ms
18,400 KB
testcase_44 AC 58 ms
28,360 KB
testcase_45 AC 51 ms
25,476 KB
testcase_46 AC 26 ms
13,704 KB
testcase_47 AC 53 ms
27,124 KB
testcase_48 AC 65 ms
31,352 KB
testcase_49 AC 114 ms
42,608 KB
testcase_50 AC 83 ms
36,760 KB
testcase_51 AC 73 ms
33,420 KB
testcase_52 AC 15 ms
8,864 KB
testcase_53 AC 20 ms
11,696 KB
testcase_54 AC 80 ms
40,696 KB
testcase_55 AC 29 ms
14,096 KB
testcase_56 AC 121 ms
50,940 KB
testcase_57 AC 94 ms
35,504 KB
testcase_58 AC 160 ms
57,852 KB
testcase_59 AC 148 ms
57,888 KB
testcase_60 AC 131 ms
57,792 KB
testcase_61 AC 110 ms
57,752 KB
testcase_62 AC 102 ms
57,856 KB
testcase_63 AC 1 ms
4,384 KB
testcase_64 AC 2 ms
4,380 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