Submission #1857308


Source Code Expand

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,n;cin>>n;
	vector<int>p(n);for(auto &it:p){cin>>it;}
	vector<int>sosa;
	while(-1){
		for(i=0;i<n;i++){
			sosa.pub(1);
			if(i==n-1){continue;}
			if(p[i]>p[i+1]){sosa.pub(n-1);swap(p[i+1],p[i]);}
		}
		int ok=1;
		for(i=0;i<n;i++){if(p[i]!=i){ok=0;break;}}
		if(ok==1){break;}
	}
	cout<<sosa.size()<<endl;
	for(auto it:sosa){cout<<it<<endl;}
	return 0;
}

Submission Info

Submission Time
Task B - Many Swaps Sorting
User WA_TLE
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1696 Byte
Status AC
Exec Time 91 ms
Memory 768 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 5 ms 768 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 2 ms 256 KB
s2_08.txt AC 2 ms 256 KB
s2_09.txt AC 2 ms 256 KB
s2_10.txt AC 3 ms 256 KB
s2_11.txt AC 3 ms 256 KB
s3_12.txt AC 19 ms 384 KB
s3_13.txt AC 36 ms 512 KB
s3_14.txt AC 10 ms 256 KB
s3_15.txt AC 10 ms 256 KB
s3_16.txt AC 90 ms 764 KB
s3_17.txt AC 72 ms 640 KB
s3_18.txt AC 73 ms 640 KB
s3_19.txt AC 91 ms 764 KB
s3_20.txt AC 1 ms 256 KB