Submission #1353716


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<LL> X(N);
	for(int i=0;i<N;++i){
		cin >> X[i];
	}
	vector<LL> D(N-1);//元
	for(int i=0;i<N-1;++i){
		D[i] = X[i+1]-X[i];
	}
	LL M,K;
	cin >> M >> K;
	vector< vector<int> > dp(64,vector<int>(N-1));
	for(int i=0;i<N-1;++i){
		dp[0][i] = i;
	}
	dp[1] = dp[0];
	
	vector<int> AA;
	for(int i=0;i<M;++i){
		int A;
		cin >> A;
		AA.push_back( A );
		swap(dp[1][A-2], dp[1][A-1]);
	}
	sort(AA.begin(), AA.end());

	for(int k=2;k<64;++k){//ダブリング
		//dp[k-1]からdp[k]を作る
		for(int i=0;i<N-1;++i){
			int pos1 = dp[k-1][i];//pos1->i
			int pos2 = dp[k-1][pos1];//pos2->pos1
			dp[k][i] = pos2;//pos2->i
		}
	}
	LL num = K;
	int pow = 1;
	vector<int> ans = dp[0];
	while(num){
		if(num&1){
			vector<int> temp = ans;
			for(int i=0;i<N-1;++i){
				int pos1 = dp[pow][ i ];//pos1->i
				temp[i] = ans[pos1];
			}
			ans = temp;
		}
		num >>=1;
		++pow;
	}
	LL now = X[0];
	cout << now << endl;
	for(int i=0;i<N-1;++i){
		now += D[ ans[i] ];
		cout << now << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()

Submission Info

Submission Time
Task C - Rabbit Exercise
User akarin55
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2254 Byte
Status AC
Exec Time 201 ms
Memory 29048 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 188 ms 28664 KB
1_03.txt AC 201 ms 29048 KB
1_04.txt AC 138 ms 19960 KB
1_05.txt AC 5 ms 640 KB
1_06.txt AC 10 ms 896 KB
1_07.txt AC 7 ms 896 KB
1_08.txt AC 10 ms 896 KB
1_09.txt AC 10 ms 896 KB
1_10.txt AC 4 ms 512 KB
1_11.txt AC 7 ms 768 KB
1_12.txt AC 2 ms 256 KB
1_13.txt AC 11 ms 1024 KB
1_14.txt AC 8 ms 896 KB
1_15.txt AC 27 ms 3136 KB
1_16.txt AC 12 ms 1792 KB
1_17.txt AC 93 ms 12504 KB
1_18.txt AC 112 ms 15660 KB
1_19.txt AC 145 ms 20716 KB
1_20.txt AC 53 ms 6392 KB
1_21.txt AC 64 ms 8568 KB
1_22.txt AC 146 ms 20716 KB
1_23.txt AC 163 ms 24628 KB
1_24.txt AC 121 ms 18312 KB
1_25.txt AC 194 ms 28280 KB