QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#75337 | #5305. Oscar is All You Need | OtoriEmu | WA | 2ms | 3412kb | C++14 | 1.6kb | 2023-02-04 21:12:55 | 2023-02-04 21:12:56 |
Judging History
answer
/*
¤ï¤ó¤ï¤ó¡¡¤ï¤ó¤À¤Û©`¤¤¤Ã¡î
Wonderhoy!
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;
char buf[1<<21],*p1=buf,*p2=buf;
#define getchar() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++)
int read()
{
int x=0;
char c=getchar();
while(c<'0' || c>'9') c=getchar();
while(c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
return x;
}
void write(int x)
{
if(x>9) write(x/10);
putchar(x%10+'0');
}
typedef pair<int,int> P;
#define mp make_pair
#define spc putchar(' ')
#define etr putchar('\n')
#define inlp(x,y) putchar(x==y?'\n':' ')
void Solve();
int main(){
int T=read();
while(T-->0) Solve();
return 0;
}
int n;
int a[1005],b[1005];
vector<P> Ans;
void swp(int p,int q)
{
int c=0;
for(int i=q+1;i<=n;++i) b[++c]=a[i];
for(int i=p;i<=q;++i) b[++c]=a[i];
for(int i=1;i<p;++i) b[++c]=a[i];
for(int i=1;i<=n;++i) a[i]=b[i];
Ans.push_back(mp(p-1,n-q));
}
int getpos(int w){return find(a+1,a+1+n,w)-a;}
void Solve()
{
Ans.clear();
n=read();
for(int i=1;i<=n;++i) a[i]=read();
if(n==3)
{
if(a[1]>a[3]) swp(2,2);
}
else
{
if(a[1]^1)
{
int p=getpos(1);
if(p==2) swp(3,3),swp(2,n-1);
else swp(p-1,p-1);
}
for(int i=2;i<=n-2;++i)
{
if(a[i]==i) continue;
int p=getpos(i);
if(p==n)
{
swp(n-2,n-2);
swp(2,n-i+1);
}
else
{
swp(i,p);
p=getpos(i);
swp(p,p);
}
}
if(a[n]^n) swp(n-2,n-1),swp(2,2),swp(2,n-1),swp(n-1,n-1),swp(2,3);
}
write(int(Ans.size())),etr;
for(auto st:Ans) write(st.first),spc,write(st.second),etr;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3372kb
input:
2 3 1 3 2 5 4 1 2 3 5
output:
0 11 2 2 1 1 1 2 3 1 2 1 2 2 2 1 1 3 1 1 3 1 1 2
result:
ok OK in maximum 11 operations
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3412kb
input:
120 3 1 3 2 3 3 2 1 3 2 3 1 5 1 2 3 4 5 12 11 9 2 8 3 10 6 1 4 7 5 12 36 24 9 7 3 31 15 13 1 4 33 11 29 16 23 2 25 35 21 32 14 6 18 17 26 28 8 27 22 20 36 10 19 34 12 30 5 4 4 2 3 1 5 3 5 2 1 4 4 1 2 4 3 10 5 7 4 9 6 8 1 3 10 2 5 3 1 5 2 4 5 3 5 1 2 4 3 3 1 2 13 3 1 2 11 12 13 8 6 5 4 10 9 7 16 12 8...
output:
0 1 1 1 1 1 1 0 24 6 5 1 3 10 1 2 8 9 2 3 7 8 3 4 6 7 4 5 5 6 5 6 1 5 6 7 1 4 7 9 2 1 8 9 4 11 0 9 1 1 10 1 1 10 1 1 9 70 6 29 1 28 34 1 2 8 33 2 3 30 32 3 4 6 31 4 5 14 30 5 6 12 29 6 7 12 28 7 8 16 27 8 9 6 26 9 10 16 25 10 11 6 24 11 12 22 23 12 13 11 22 13 14 8 21 14 15 18 20 15 16 13 19 16 33 2...
result:
wrong answer x+y is greater than n