Submission #3817462


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_M = (int)2e5 + 5;

int A[MAX_M];

bool isSame(vector<int> a, vector<int> b){
	int n = (int)a.size();
	rep (i, n){
		if (a[i] != b[i]) return false;
	} // end rep
	return true;
}

int main()
{
	memset(A, 0, sizeof(A));
	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

	vector<int> n(N, 0);
	rep (i, N) n[i] = i;
	vector<int> origN = n;

	int repeatD = 0;
	while(true){
		rep (j, M){
			swap (n[A[j]], n[A[j]+1]);
		} // end rep
		++repeatD;
		if (isSame(n, origN)){
			break;
		} // end if		
	} // end while

//	cerr << "repeatD: " << repeatD << endl;

	n = origN;
	rep (d, D % repeatD){
		rep (j, M){
			swap (n[A[j]], n[A[j]+1]);
		} // end rep
	} // end rep
	vector<int> pos(N, 0);
	rep (i, N){
		pos[n[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 1146 Byte
Status TLE
Exec Time 4207 ms
Memory 2816 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 2800 KB
01_random01.txt AC 2 ms 1024 KB
01_random02.txt AC 2 ms 1024 KB
01_random03.txt AC 2 ms 1024 KB
01_random04.txt TLE 4203 ms 1152 KB
01_random05.txt AC 403 ms 2816 KB
01_random06.txt TLE 4203 ms 2672 KB
01_random07.txt TLE 4203 ms 2656 KB
02_i.txt AC 3 ms 1024 KB
02_p.txt TLE 4203 ms 1024 KB
02_random01.txt AC 2 ms 1024 KB
02_random02.txt AC 2 ms 1024 KB
02_random03.txt AC 2288 ms 1024 KB
02_random04.txt AC 3 ms 1024 KB
02_random05.txt TLE 4203 ms 1024 KB
02_random06.txt TLE 4207 ms 1024 KB
02_random07.txt TLE 4203 ms 1024 KB
02_random08.txt TLE 4203 ms 1024 KB
02_rp01.txt AC 1500 ms 1024 KB
02_rp02.txt TLE 4203 ms 1024 KB
02_rp03.txt AC 895 ms 1024 KB
02_rp04.txt TLE 4203 ms 1024 KB
02_rp05.txt TLE 4203 ms 1024 KB
03_i.txt AC 2 ms 1024 KB
03_random01.txt AC 3 ms 1024 KB
03_random02.txt AC 13 ms 1024 KB
03_random03.txt AC 11 ms 1024 KB
03_random04.txt AC 11 ms 1024 KB
03_random05.txt AC 3 ms 1024 KB
03_random06.txt AC 3 ms 1024 KB
03_random07.txt AC 5 ms 1024 KB
03_random08.txt AC 2 ms 1024 KB
03_random09.txt AC 6 ms 1024 KB
03_random10.txt AC 8 ms 1024 KB
03_random11.txt AC 15 ms 1024 KB
03_random12.txt AC 15 ms 1024 KB
03_random13.txt AC 11 ms 1024 KB
03_random14.txt AC 10 ms 1024 KB
03_random15.txt AC 5 ms 1024 KB
04_i.txt AC 167 ms 2800 KB
04_p1.txt TLE 4203 ms 2668 KB
04_p2.txt TLE 4203 ms 2344 KB
04_random01.txt TLE 4203 ms 1968 KB
04_random02.txt TLE 4203 ms 1904 KB
04_random03.txt TLE 4203 ms 1152 KB
04_random04.txt TLE 4203 ms 1152 KB
04_random05.txt TLE 4203 ms 1280 KB
04_random06.txt TLE 4203 ms 2040 KB
04_random07.txt TLE 4203 ms 1656 KB
04_random08.txt TLE 4203 ms 1572 KB
04_random09.txt TLE 4203 ms 1368 KB
04_random10.txt TLE 4203 ms 2056 KB
04_random11.txt TLE 4203 ms 2672 KB
04_random12.txt TLE 4203 ms 2672 KB
04_random13.txt TLE 4203 ms 2656 KB
04_rp01.txt TLE 4203 ms 2656 KB
04_rp02.txt TLE 4203 ms 2672 KB
04_rp03.txt TLE 4203 ms 2656 KB
04_rp04.txt TLE 4203 ms 2656 KB
04_rp05.txt TLE 4203 ms 2672 KB
04_rp06.txt TLE 4203 ms 2656 KB
04_rp07.txt TLE 4203 ms 2672 KB
04_rp08.txt TLE 4203 ms 2656 KB
04_rp09.txt TLE 4203 ms 2672 KB
04_rp10.txt TLE 4203 ms 2656 KB
sample_1.txt AC 2 ms 1024 KB
sample_2.txt AC 2 ms 1024 KB
sample_3.txt AC 2 ms 1024 KB