Submission #2151456


Source Code Expand

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 205;
const int MM = 1000000007;

int D[MX];
int N;
vector<int> L;

void rot(int k){
	L.push_back(k);
	for(int i=k;i<N;i++)
		swap(D[i],D[i-k]);
}

int main()
{
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", D+i);
	for(int i = 1; i <= N; i++){
		rot(1);
		for(int j = 1; j < N; j++){
			if(D[0] < D[N-1]) rot(N-1);
			rot(1);
		}
	}
	printf("%d\n", L.size());
	for(int c : L) printf("%d\n", c);
}

Submission Info

Submission Time
Task B - Many Swaps Sorting
User zigui
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1584 Byte
Status AC
Exec Time 19 ms
Memory 764 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:76:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type {aka long unsigned int}’ [-Wformat=]
  printf("%d\n", L.size());
                         ^
./Main.cpp:67:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
./Main.cpp:68:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < N; i++) scanf("%d", D+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 2 ms 384 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 384 KB
s3_13.txt AC 8 ms 512 KB
s3_14.txt AC 2 ms 384 KB
s3_15.txt AC 2 ms 384 KB
s3_16.txt AC 19 ms 764 KB
s3_17.txt AC 18 ms 640 KB
s3_18.txt AC 18 ms 640 KB
s3_19.txt AC 19 ms 764 KB
s3_20.txt AC 17 ms 640 KB