Submission #2901955


Source Code Expand

#include <bits/stdc++.h>
#define L long long

using namespace std;

L n;
L a[222];

L operation(L x){
	L i;
	for(i=x+1;i<=n;i++)
	{
		swap(a[i],a[i-x]);
	}
}

L fin(L x){
	L i;
	for(i=1;i<=n;i++)
	{
		if(a[i]==x) return i;
	}
}

int main()
{
	scanf("%lld",&n);
	L i;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]++;
	}
	vector<L>ans;
	for(i=n;i>1;i--)
	{
		while(fin(i-1)!=1)
		{
			ans.push_back(1);
			operation(1);
		}
		while(fin(i)!=2)
		{
			ans.push_back(1);
			operation(1);
			ans.push_back(n-1);
			operation(n-1);
		}
	}
	printf("%lld\n",ans.size());
	for(i=0;i<ans.size();i++)
	{
		printf("%lld\n",ans[i]);
	}
	/*for(i=1;i<=n;i++)
	{
		printf("%lld ",a[i]);
	}*/
}

Submission Info

Submission Time
Task B - Many Swaps Sorting
User gs16103
Language C++14 (GCC 5.4.1)
Score 900
Code Size 740 Byte
Status AC
Exec Time 21 ms
Memory 1016 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:50:28: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘std::vector<long long int>::size_type {aka long unsigned int}’ [-Wformat=]
  printf("%lld\n",ans.size());
                            ^
./Main.cpp:27:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
                  ^
./Main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^

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 256 KB
00_example_02.txt AC 1 ms 256 KB
s1_01.txt AC 1 ms 256 KB
s1_02.txt AC 1 ms 256 KB
s1_03.txt AC 1 ms 256 KB
s1_04.txt AC 1 ms 256 KB
s1_05.txt AC 1 ms 256 KB
s1_06.txt AC 1 ms 256 KB
s2_07.txt AC 1 ms 256 KB
s2_08.txt AC 1 ms 256 KB
s2_09.txt AC 1 ms 256 KB
s2_10.txt AC 1 ms 256 KB
s2_11.txt AC 1 ms 256 KB
s3_12.txt AC 4 ms 512 KB
s3_13.txt AC 9 ms 640 KB
s3_14.txt AC 3 ms 384 KB
s3_15.txt AC 2 ms 384 KB
s3_16.txt AC 21 ms 1016 KB
s3_17.txt AC 20 ms 892 KB
s3_18.txt AC 20 ms 892 KB
s3_19.txt AC 21 ms 1016 KB
s3_20.txt AC 20 ms 892 KB