Submission #1962368
Source Code Expand
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[210];
int q[210];
vector<pair<int,int> > mr;
int N;
void wolf(int a){
for(int i=a;i<N;i++)swap(p[i],p[i-a]);
// printf("%d: ",a);
for(int i=0;i<N;i++){
// if(i)printf(" ");
// printf("%d",p[i]);
}
// printf("\n");
}
int main(){
int a;scanf("%d",&a);
N=a;
for(int i=0;i<a;i++){scanf("%d",p+i);}
for(int i=0;i<a;i++)q[i]=p[i];
for(int i=0;i<a;i++){
for(int j=1;j<a;j++){
if(q[j]<q[j-1]){
mr.push_back(make_pair(j-1,j));
swap(q[j],q[j-1]);
}
}
}
vector<int>ret;
int ori=0;
for(int i=0;i<mr.size();i++){
int L=mr[i].first;
int rem=(L+1-ori+a)%a;
while(rem){
int mv=min(rem,1);
ret.push_back(mv);
wolf(mv);
rem-=mv;
}
ret.push_back(a-1);
wolf(a-1);
ori=(L+1)%a;
}
int rem=(a-ori)%a;
while(rem){
int mv=min(rem,1);
ret.push_back(mv);
wolf(mv);
rem-=mv;
}
assert(ret.size()<=100000);
printf("%d\n",ret.size());
for(int i=0;i<ret.size();i++){
printf("%d\n",ret[i]);
}
}
Submission Info
Submission Time
2018-01-11 12:29:30+0900
Task
B - Many Swaps Sorting
User
tozangezan
Language
C++14 (GCC 5.4.1)
Score
900
Code Size
1707 Byte
Status
AC
Exec Time
19 ms
Memory
892 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:71:29: 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",ret.size());
^
./Main.cpp:35:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int a;scanf("%d",&a);
^
./Main.cpp:37:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=0;i<a;i++){scanf("%d",p+i);}
^
Judge Result
Set Name
Sample
Subtask1
Subtask2
All
Score / Max Score
0 / 0
300 / 300
400 / 400
200 / 200
Status
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
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
892 KB
s3_17.txt
AC
17 ms
764 KB
s3_18.txt
AC
17 ms
768 KB
s3_19.txt
AC
19 ms
892 KB
s3_20.txt
AC
1 ms
256 KB