Submission #48929123
Source Code Expand
// LUOGU_RID: 141419756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)
#ifdef EXODUS
#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define Debug(...) 0
#endif
//=========================================================================================================
// Something about IO
template<typename T>
void read(T &x){
x=0;T flg=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}
//=========================================================================================================
// Define the global variables here.
bool membg=0;
constexpr int N=1e3+7;
int n;
int a[N];
bool memed=0;
//=========================================================================================================
// Code here.
void solve(){
read(n);
for(int i=1;i<=n;i++)read(a[i]);
int icnt=0;
for(int i=1;i<=n;i++)
for(int j=1;j<i;j++)
icnt+=(a[j]>a[i]);
if(icnt&1)return printf("No\n"),void();
vector<pair<int,int>>ans;
for(int i=1;i<=n-2;i++){
if(a[n]==i)ans.eb(n-1,n-3),swap(a[n-2],a[n-1]),swap(a[n-1],a[n]);
for(int j=1;j<=n;j++)
if(a[j]==i){
if(j!=i){
for(int k=j;k>i;k--)swap(a[k],a[k-1]),swap(a[k+1],a[k]);
ans.eb(j,i-1);
}
break;
}
}
printf("Yes\n");
printf("%d\n",(int)ans.size());
for(auto [x,y]:ans)printf("%d %d\n",x,y);
return;
}
//=========================================================================================================
int main(){
Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
int timbg=clock();
int T=1;
while(T--)solve();
int timed=clock();
Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
fflush(stdout);
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Insertion Sort 2 |
| User |
EXODUS |
| Language |
C++ 20 (gcc 12.2) |
| Score |
500 |
| Code Size |
2209 Byte |
| Status |
AC |
| Exec Time |
2 ms |
| Memory |
3896 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:77:9: note: in expansion of macro ‘Debug’
77 | Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
| ^~~~~
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:82:9: note: in expansion of macro ‘Debug’
82 | Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
| ^~~~~
Main.cpp:78:13: warning: unused variable ‘timbg’ [-Wunused-variable]
78 | int timbg=clock();
| ^~~~~
Main.cpp:81:13: warning: unused variable ‘timed’ [-Wunused-variable]
81 | int timed=clock();
| ^~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
500 / 500 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 02_handmade_01.txt, 02_handmade_02.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_01.txt |
AC |
1 ms |
3804 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3552 KiB |
| 00_sample_03.txt |
AC |
1 ms |
3816 KiB |
| 01_test_01.txt |
AC |
1 ms |
3692 KiB |
| 01_test_02.txt |
AC |
2 ms |
3896 KiB |
| 01_test_03.txt |
AC |
1 ms |
3628 KiB |
| 01_test_04.txt |
AC |
1 ms |
3524 KiB |
| 01_test_05.txt |
AC |
2 ms |
3716 KiB |
| 01_test_06.txt |
AC |
1 ms |
3568 KiB |
| 01_test_07.txt |
AC |
1 ms |
3496 KiB |
| 01_test_08.txt |
AC |
1 ms |
3832 KiB |
| 01_test_09.txt |
AC |
1 ms |
3748 KiB |
| 01_test_10.txt |
AC |
1 ms |
3636 KiB |
| 01_test_11.txt |
AC |
2 ms |
3692 KiB |
| 01_test_12.txt |
AC |
1 ms |
3596 KiB |
| 01_test_13.txt |
AC |
1 ms |
3560 KiB |
| 01_test_14.txt |
AC |
2 ms |
3812 KiB |
| 01_test_15.txt |
AC |
1 ms |
3508 KiB |
| 01_test_16.txt |
AC |
1 ms |
3816 KiB |
| 01_test_17.txt |
AC |
1 ms |
3556 KiB |
| 01_test_18.txt |
AC |
1 ms |
3556 KiB |
| 01_test_19.txt |
AC |
1 ms |
3684 KiB |
| 01_test_20.txt |
AC |
1 ms |
3872 KiB |
| 01_test_21.txt |
AC |
1 ms |
3560 KiB |
| 02_handmade_01.txt |
AC |
2 ms |
3784 KiB |
| 02_handmade_02.txt |
AC |
2 ms |
3848 KiB |