Submission #1833764


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int m[666666];
int* a=m;
int op[111111],pop;
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)a[i]=io::F();
	int cnt=0;
	if(a[1]==n-1)a[n+1]=a[1],++a,op[++pop]=1;
	while(1)
	{
		if(cnt%n==0)
		{
			int fl=1;
			for(register int i=1;i<n;++i)if(a[i]>a[i+1])fl=0;
			if(fl)break;
		}
		else if(a[1]<a[n])std::swap(a[1],a[n]),op[++pop]=n-1;
		a[n+1]=a[1];
		++a;
		op[++pop]=1;
		++cnt;
	}
	printf("%d\n",pop);
	for(register int i=1;i<=pop;++i)printf("%d\n",op[i]);
	return 0;
}


Submission Info

Submission Time
Task B - Many Swaps Sorting
User ESpace
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1276 Byte
Status AC
Exec Time 5 ms
Memory 640 KB

Judge Result

Set Name Sample Subtask1 Subtask2 All
Score / Max Score 0 / 0 300 / 300 400 / 400 200 / 200
Status
AC × 2
AC × 7
AC × 13
AC × 22
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 128 KB
00_example_02.txt AC 0 ms 128 KB
s1_01.txt AC 1 ms 128 KB
s1_02.txt AC 1 ms 128 KB
s1_03.txt AC 1 ms 128 KB
s1_04.txt AC 1 ms 128 KB
s1_05.txt AC 1 ms 128 KB
s1_06.txt AC 0 ms 128 KB
s2_07.txt AC 1 ms 128 KB
s2_08.txt AC 1 ms 128 KB
s2_09.txt AC 1 ms 128 KB
s2_10.txt AC 1 ms 128 KB
s2_11.txt AC 1 ms 128 KB
s3_12.txt AC 2 ms 256 KB
s3_13.txt AC 2 ms 384 KB
s3_14.txt AC 1 ms 256 KB
s3_15.txt AC 1 ms 256 KB
s3_16.txt AC 5 ms 640 KB
s3_17.txt AC 4 ms 640 KB
s3_18.txt AC 4 ms 640 KB
s3_19.txt AC 5 ms 640 KB
s3_20.txt AC 0 ms 128 KB