QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397235#5305. Oscar is All You NeedmarherWA 2ms3696kbC++171.2kb2024-04-23 20:07:512024-04-23 20:07:51

Judging History

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

  • [2024-04-23 20:07:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3696kb
  • [2024-04-23 20:07:51]
  • 提交

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';
    // for(int i=1;i<=n;i++)cout<<a[i]<<' ';
}

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=2;i<=n;i++)if(a[i]==n)pos=i;
    if(pos==n)mk(1,2),mk(1,1);
    else if(pos>=3)mk(1,1),mk(pos-1,1);
    for(int i=2;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: 3692kb

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: 2ms
memory: 3696kb

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

result:

wrong answer Integer parameter [name=operations] equals to 14, violates the range [0, 13]