Submission #42719092
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
vector<pair<ll,ll> > vec;
ll n,p[1010];
void mdf(ll x,ll y){
vec.push_back(MP(x,y));
ll tmp1=p[x],tmp2=p[x+1];
pfr(i,x-1,y+1) p[i+2]=p[i];
p[y+1]=tmp1;
p[y+2]=tmp2;
}
int main(){
n=read();
fr(i,1,n) p[i]=read();
fr(i,1,n-2){
ll pos=0;
fr(j,1,n) if(p[j]==i) pos=j;
if(pos==i) continue;
if(pos==n){
mdf(n-1,n-3);
pos=n-1;
}
mdf(pos,i-1);
}
if(p[n-1]<p[n]){
pf("Yes\n");
writeln((ll)vec.size());
fr(i,0,(ll)vec.size()-1) pf("%lld %lld\n",vec[i].fir,vec[i].sec);
}
else pf("No");
}
Submission Info
| Submission Time |
|
| Task |
B - Insertion Sort 2 |
| User |
AFewSuns |
| Language |
C++ (GCC 9.2.1) |
| Score |
500 |
| Code Size |
1840 Byte |
| Status |
AC |
| Exec Time |
6 ms |
| Memory |
3704 KiB |
Compile Error
./Main.cpp: In function ‘void mdf(long long int, long long int)’:
./Main.cpp:77:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
77 | pfr(i,x-1,y+1) p[i+2]=p[i];
| ^
./Main.cpp:30:37: note: in definition of macro ‘pfr’
30 | #define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
| ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:83:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
83 | fr(i,1,n) p[i]=read();
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:84:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
84 | fr(i,1,n-2){
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:86:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
86 | fr(j,1,n) if(p[j]==i) pos=j;
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
./Main.cpp:97:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
97 | fr(i,0,(ll)vec.size()-1) pf("%lld %lld\n",vec[i].fir,vec[i].sec);
| ^
./Main.cpp:29:36: note: in definition of macro ‘fr’
29 | #define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
| ^
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 |
3500 KiB |
| 00_sample_02.txt |
AC |
2 ms |
3604 KiB |
| 00_sample_03.txt |
AC |
2 ms |
3504 KiB |
| 01_test_01.txt |
AC |
1 ms |
3496 KiB |
| 01_test_02.txt |
AC |
5 ms |
3584 KiB |
| 01_test_03.txt |
AC |
3 ms |
3412 KiB |
| 01_test_04.txt |
AC |
6 ms |
3492 KiB |
| 01_test_05.txt |
AC |
3 ms |
3560 KiB |
| 01_test_06.txt |
AC |
4 ms |
3632 KiB |
| 01_test_07.txt |
AC |
4 ms |
3516 KiB |
| 01_test_08.txt |
AC |
2 ms |
3704 KiB |
| 01_test_09.txt |
AC |
2 ms |
3628 KiB |
| 01_test_10.txt |
AC |
2 ms |
3484 KiB |
| 01_test_11.txt |
AC |
3 ms |
3580 KiB |
| 01_test_12.txt |
AC |
3 ms |
3572 KiB |
| 01_test_13.txt |
AC |
4 ms |
3628 KiB |
| 01_test_14.txt |
AC |
4 ms |
3592 KiB |
| 01_test_15.txt |
AC |
3 ms |
3440 KiB |
| 01_test_16.txt |
AC |
2 ms |
3412 KiB |
| 01_test_17.txt |
AC |
2 ms |
3412 KiB |
| 01_test_18.txt |
AC |
2 ms |
3552 KiB |
| 01_test_19.txt |
AC |
2 ms |
3504 KiB |
| 01_test_20.txt |
AC |
2 ms |
3524 KiB |
| 01_test_21.txt |
AC |
3 ms |
3524 KiB |
| 02_handmade_01.txt |
AC |
4 ms |
3644 KiB |
| 02_handmade_02.txt |
AC |
6 ms |
3588 KiB |