QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#306204 | #5305. Oscar is All You Need | lnyx | WA | 0ms | 3556kb | C++14 | 2.0kb | 2024-01-16 15:13:07 | 2024-01-16 15:13:07 |
Judging History
answer
// 距离退役还有 47 天
#include<cstdio>
#include<iostream>
#include<vector>
#define eb emplace_back
using namespace std;
namespace IO{
template<typename T> inline void rd(T &x){
x=0; bool f=0; char c=getchar();
while(c<'0'||c>'9') f|=c=='-',c=getchar();
while('0'<=c&&c<='9') x=((x<<3)+(x<<1))+(c^48),c=getchar();
x=f?-x:x;
}
template<typename T,typename ...Args> inline void rd(T &x,Args &...args){ rd(x),rd(args...); }
template<typename T> inline void wt(char c,T x){
static int stk[114]; int top=0;
if(x<0) x=-x,putchar('-');
do stk[++top]=x%10,x/=10; while(x);
while(top) putchar(stk[top--]+'0');
putchar(c);
}
template<typename T,typename ...Args> inline void wt(char c,T x,Args ...args){ wt(c,x),wt(c,args...); }
template<typename T,typename ...Args> inline void wt(char c1,char c2,T x,Args ...args){ wt(c2,x),wt(c2,args...),putchar(c1); }
}
using IO::rd;
using IO::wt;
typedef pair<int,int> PII;
const int N=1007;
int n;
int p[N],tmp[N];
vector<PII>ans;
inline void change(int x,int y){
ans.eb(x,y);
int cnt=0;
for(int i=n-y+1;i<=n;i++) tmp[++cnt]=p[i];
for(int i=x+1;i<n-y+1;i++) tmp[++cnt]=p[i];
for(int i=1;i<=x;i++) tmp[++cnt]=p[i];
for(int i=1;i<=n;i++) p[i]=tmp[i];
}
inline void solve(){
rd(n);
for(int i=1;i<=n;i++) rd(p[i]);
if(n==3){
if(p[3]<p[1]) puts("1\n1 3");
else puts("0");
return ;
}
if(p[1]!=1){
if(p[2]==1) change(1,2);
int pos=0;
for(int i=1;i<=n;i++){
if(p[i]==1){ pos=i; break; }
}
change(1,n-pos+1);
}
for(int len=1;len<=n-2;len++){
int pos=0;
for(int i=1;i<=len;i++){
if(p[i]<p[n]) pos=i;
}
change(pos,2),change(1,pos);
}
/*
1 2 4 3
3 4 1 2
2 4 1 3
1 3 4 2
4 2 3 1
1 2 3 4
*/
if(p[n-1]>p[n]) change(n-2,1),change(1,1),change(1,n-2),change(1,n-2),change(1,1);
wt('\n',(int)ans.size());
for(PII A:ans) wt('\n',' ',A.first,A.second);
}
int main(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
int T; rd(T);
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3556kb
input:
2 3 1 3 2 5 4 1 2 3 5
output:
0 13 1 2 1 3 1 2 1 1 2 2 1 2 2 2 1 2 3 1 1 1 1 3 1 3 1 1
result:
wrong answer Integer parameter [name=operations] equals to 13, violates the range [0, 11]