QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397226#5305. Oscar is All You NeedmarherWA 1ms3708kbC++171.1kb2024-04-23 19:55:212024-04-23 19:55:21

Judging History

你现在查看的是最新测评结果

  • [2024-04-23 19:55:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-04-23 19:55:21]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e3+50;

struct node
{
    int l,r;
}p[N];

int T,n,a[N],tot,b[N];

void print()
{
    cout<<tot<<'\n';
    for(int i=1;i<=tot;i++)cout<<p[i].l<<' '<<p[i].r<<'\n';
}

void mk(int l,int r)
{
    int cc=0;
    for(int i=n-r+1;i<=n;i++)b[++cc]=a[i];
    for(int i=l+1;i<=n-r;i++)b[++cc]=a[i];
    for(int i=1;i<=l;i++)b[++cc]=a[i];
    swap(a,b);p[++tot]=(node){l,r};
}

void sol()
{
    cin>>n;tot=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    if(n==3)
    {
        if(a[1]>a[3])mk(1,1);
        return;
    }
    int pos=1;
    for(int i=2;i<=n;i++)if(a[i]==1)pos=i;
    if(pos==2)mk(2,1),mk(1,1);
    if(pos>2)mk(1,n-pos+1);
    for(int i=1;i<n;i++)
    {
        int x=a[n],t=1;
        for(int j=1;j<=i;j++)if(a[j]<x)t=j;
        if(t==i&&n==i+1)continue;
        if(t>=n-2)break;
        mk(t,2);mk(1,t);
    }
    if(a[n]==n)return;
    mk(1,1);mk(n-2,1);mk(2,n-3);mk(n-3,1);mk(1,n-2);
}

main()
{
    // freopen("in.txt","r",stdin);
    cin>>T;
    while(T--)sol(),print();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

input:

2
3
1 3 2
5
4 1 2 3 5

output:

0
10
2 1
1 1
1 2
1 1
1 2
1 1
1 2
1 1
1 2
1 1

result:

ok OK in maximum 10 operations

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3708kb

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
8
1 2
1 1
1 2
1 1
1 2
1 1
1 2
1 1
23
1 5
1 2
1 1
1 2
1 1
2 2
1 2
1 2
1 1
3 2
1 3
1 2
1 1
5 2
1 5
8 2
1 8
3 2
1 3
5 2
1 5
3 2
1 3
71
1 29
1 2
1 1
1 2
1 1
2 2
1 2
4 2
1 4
1 2
1 1
2 2
1 2
3 2
1 3
2 2
1 2
8 2
1 8
5 2
1 5
11 2
1 11
8 2
1 8
5 2
1 5
14 2
1 14
10 2
1 10
11 2
1 11
13 2
1 13
4 2...

result:

wrong answer Jury have smaller lexicographical order