Submission #2018595


Source Code Expand

#include <iostream>
#include <ctime>
#include <vector>
using namespace std;

int n, a[100009]; vector<int>F;

void shuffle(int p) {
	for (int i = p; i < n; i++) swap(a[i], a[i - p]);
}
bool isperm() {
	for (int i = 0; i < n; i++) { if (a[i] != i) return false; }
	return true;
}

int main() {
	srand((unsigned)time(NULL));
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	while (true) {
		if (isperm() == true)break;
		int I = rand() % (n - 1) + 1;
		F.push_back(I);
		shuffle(I);
	}
	cout << F.size() << endl;
	for (int i = 0; i < F.size(); i++)cout << F[i] << endl;
	return 0;
}

Submission Info

Submission Time
Task B - Many Swaps Sorting
User E869120
Language C++14 (GCC 5.4.1)
Score 300
Code Size 612 Byte
Status TLE
Exec Time 2104 ms
Memory 264536 KB

Judge Result

Set Name Sample Subtask1 Subtask2 All
Score / Max Score 0 / 0 300 / 300 0 / 400 0 / 200
Status
AC × 2
AC × 7
AC × 8
TLE × 5
AC × 9
TLE × 13
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
Subtask1 00_example_01.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt
Subtask2 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s2_07.txt, s2_08.txt, s2_09.txt, s2_10.txt, s2_11.txt
All 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s2_07.txt, s2_08.txt, s2_09.txt, s2_10.txt, s2_11.txt, s3_12.txt, s3_13.txt, s3_14.txt, s3_15.txt, s3_16.txt, s3_17.txt, s3_18.txt, s3_19.txt, s3_20.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 151 ms 892 KB
s1_01.txt AC 1 ms 256 KB
s1_02.txt AC 4 ms 256 KB
s1_03.txt AC 5 ms 256 KB
s1_04.txt AC 5 ms 256 KB
s1_05.txt AC 12 ms 384 KB
s1_06.txt AC 1 ms 256 KB
s2_07.txt TLE 2104 ms 263768 KB
s2_08.txt TLE 2104 ms 264536 KB
s2_09.txt TLE 2104 ms 264536 KB
s2_10.txt TLE 2104 ms 263128 KB
s2_11.txt TLE 2104 ms 264152 KB
s3_12.txt TLE 2104 ms 131548 KB
s3_13.txt TLE 2103 ms 131676 KB
s3_14.txt TLE 2104 ms 131676 KB
s3_15.txt TLE 2104 ms 131804 KB
s3_16.txt TLE 2103 ms 66016 KB
s3_17.txt TLE 2104 ms 67552 KB
s3_18.txt TLE 2103 ms 66144 KB
s3_19.txt TLE 2104 ms 67808 KB
s3_20.txt AC 1 ms 256 KB