Submission #3818069


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = (int)2e5 + 5;

int A[MAX_N];
int arr[MAX_N];
int orgArr[MAX_N];

int changeOne[MAX_N];
int trans[MAX_N];

int newArr[MAX_N];
int pos[MAX_N];
bool isSame(int n, int a[], int b[]){
	rep (i, n){
		if (a[i] != b[i]) return false;
	} // end rep
	return true;
}

int main()
{
	memset(A, 0, sizeof(A));
	memset(arr, 0, sizeof(arr));
	memset(orgArr, 0, sizeof(orgArr));
	memset(changeOne, 0, sizeof(changeOne));	
	memset(trans, 0, sizeof(trans));	
	memset(newArr, 0, sizeof(newArr));
	memset(pos, 0, sizeof(pos));

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M, D; cin >> N >> M >> D;
	rep (i, M){
		int a; cin >> a;
		--a;
		A[i] = a;
	} // end rep

	rep (i, N) arr[i] = i;
	memcpy(orgArr, arr, sizeof(int)*N);
	rep (j, M){
		swap (arr[A[j]], arr[A[j]+1]);
	} // end rep

	memcpy(changeOne, arr, sizeof(int)*N); // 一回の阿弥陀くじで変化した数列
	rep (i, N){
		trans[changeOne[i]] = i;	// 何がどの場所に行ったかの変換
	} // end rep

	memcpy(arr, orgArr, sizeof(int)*N);

	int repeatD = 0;
	while(true){
		rep (i, N){
			newArr[trans[i]] = arr[i];
		} // end rep

		memcpy(arr, newArr, sizeof(int)*N);

		++repeatD;
		if (isSame(N, arr, orgArr)){
			break;
		} // end if		
	} // end while

	memcpy(arr, orgArr, sizeof(int)*N);
	rep (d, D % repeatD){
		rep (i, N){
			newArr[trans[i]] = arr[i];
		} // end rep
		memcpy(arr, newArr, sizeof(int)*N);
	} // end rep

	rep (i, N){
		pos[arr[i]] = i;
	} // end rep
	
	rep (i, N){
		cout << pos[i] + 1 << endl;
	} // end rep

	return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User ty70
Language C++14 (GCC 5.4.1)
Score 20
Code Size 1788 Byte
Status TLE
Exec Time 4204 ms
Memory 6272 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 0 / 10 0 / 20 20 / 20 0 / 50
Status
AC × 6
TLE × 3
AC × 10
TLE × 8
AC × 18
AC × 4
TLE × 25
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 166 ms 6272 KB
01_random01.txt AC 4 ms 5760 KB
01_random02.txt AC 4 ms 5760 KB
01_random03.txt AC 4 ms 5760 KB
01_random04.txt TLE 4204 ms 5760 KB
01_random05.txt AC 231 ms 6272 KB
01_random06.txt TLE 4204 ms 5760 KB
01_random07.txt TLE 4204 ms 5760 KB
02_i.txt AC 6 ms 5760 KB
02_p.txt TLE 4204 ms 5760 KB
02_random01.txt AC 4 ms 5760 KB
02_random02.txt AC 4 ms 5760 KB
02_random03.txt AC 223 ms 5760 KB
02_random04.txt AC 5 ms 5760 KB
02_random05.txt TLE 4204 ms 5760 KB
02_random06.txt TLE 4204 ms 5760 KB
02_random07.txt TLE 4204 ms 5760 KB
02_random08.txt TLE 4204 ms 5760 KB
02_rp01.txt AC 590 ms 5760 KB
02_rp02.txt TLE 4204 ms 5760 KB
02_rp03.txt AC 354 ms 5760 KB
02_rp04.txt TLE 4204 ms 5760 KB
02_rp05.txt TLE 4204 ms 5760 KB
03_i.txt AC 4 ms 5760 KB
03_random01.txt AC 5 ms 5760 KB
03_random02.txt AC 15 ms 5760 KB
03_random03.txt AC 13 ms 5760 KB
03_random04.txt AC 13 ms 5760 KB
03_random05.txt AC 6 ms 5760 KB
03_random06.txt AC 6 ms 5760 KB
03_random07.txt AC 7 ms 5760 KB
03_random08.txt AC 4 ms 5760 KB
03_random09.txt AC 7 ms 5760 KB
03_random10.txt AC 10 ms 5760 KB
03_random11.txt AC 14 ms 5760 KB
03_random12.txt AC 15 ms 5760 KB
03_random13.txt AC 12 ms 5760 KB
03_random14.txt AC 11 ms 5760 KB
03_random15.txt AC 7 ms 5760 KB
04_i.txt AC 169 ms 6272 KB
04_p1.txt TLE 4204 ms 5760 KB
04_p2.txt TLE 4204 ms 5760 KB
04_random01.txt TLE 4204 ms 5760 KB
04_random02.txt TLE 4204 ms 5760 KB
04_random03.txt TLE 4204 ms 5760 KB
04_random04.txt TLE 4204 ms 5760 KB
04_random05.txt TLE 4204 ms 5760 KB
04_random06.txt TLE 4204 ms 5760 KB
04_random07.txt TLE 4204 ms 5760 KB
04_random08.txt TLE 4204 ms 5760 KB
04_random09.txt TLE 4204 ms 5760 KB
04_random10.txt TLE 4204 ms 5760 KB
04_random11.txt TLE 4204 ms 5760 KB
04_random12.txt TLE 4204 ms 5760 KB
04_random13.txt TLE 4204 ms 5760 KB
04_rp01.txt TLE 4204 ms 5760 KB
04_rp02.txt TLE 4204 ms 5760 KB
04_rp03.txt TLE 4204 ms 5760 KB
04_rp04.txt TLE 4204 ms 5760 KB
04_rp05.txt TLE 4204 ms 5760 KB
04_rp06.txt TLE 4204 ms 5760 KB
04_rp07.txt TLE 4204 ms 5760 KB
04_rp08.txt TLE 4204 ms 5760 KB
04_rp09.txt TLE 4204 ms 5760 KB
04_rp10.txt TLE 4204 ms 5760 KB
sample_1.txt AC 4 ms 5760 KB
sample_2.txt AC 4 ms 5760 KB
sample_3.txt AC 4 ms 5760 KB