QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397274#5305. Oscar is All You NeedmarherRE 1ms3708kbC++171.3kb2024-04-23 21:10:192024-04-23 21:10:20

Judging History

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

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

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++)
    {
        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&&a[n-1]!=n-1)
    {
        int x=a[n-1]-1,y=n-1-a[n-1];
        mk(x,2);mk(1,x+y);mk(y,1);mk(1,y+1);mk(1,x+1);
        return;
    }
    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);
    // freopen("out.txt","w",stdout);
    cin>>T;
    while(T--)sol(),print();
}

詳細信息

Test #1:

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

input:

2
3
1 3 2
5
4 1 2 3 5

output:

0
8
2 1
1 1
2 2
1 2
2 2
1 2
2 2
1 2

result:

ok OK in maximum 8 operations

Test #2:

score: 0
Accepted
time: 1ms
memory: 3648kb

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
6
2 2
1 2
2 2
1 2
2 2
1 2
21
1 5
2 2
1 2
2 2
1 2
3 2
1 3
1 2
1 1
4 2
1 4
1 2
1 1
6 2
1 6
9 2
1 9
4 2
1 4
6 2
1 6
69
1 29
2 2
1 2
2 2
1 2
3 2
1 3
5 2
1 5
1 2
1 1
3 2
1 3
4 2
1 4
3 2
1 3
9 2
1 9
6 2
1 6
12 2
1 12
9 2
1 9
6 2
1 6
15 2
1 15
11 2
1 11
12 2
1 12
14 2
1 14
5 2
1 5
16 2
1 16
1...

result:

ok OK in maximum 1 operations

Test #3:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

120
8
1 4 5 2 6 7 3 8
15
3 8 13 15 6 9 4 11 5 2 10 14 12 7 1
3
2 3 1
8
5 8 3 4 2 1 6 7
4
2 4 3 1
8
2 5 7 4 1 8 6 3
5
3 4 2 1 5
5
1 4 5 3 2
21
8 16 7 18 15 20 17 19 9 11 14 2 3 21 6 10 13 4 12 5 1
8
7 1 8 4 5 3 6 2
3
3 1 2
3
3 2 1
6
4 1 6 3 2 5
7
6 7 5 4 3 2 1
21
4 6 9 10 18 3 19 2 16 13 5 12 21 15 1...

output:

12
2 2
1 2
1 2
1 1
3 2
1 3
3 2
1 3
1 2
1 1
4 2
1 4
28
1 1
1 2
1 1
2 2
1 2
4 2
1 4
5 2
1 5
4 2
1 4
1 2
1 1
3 2
1 3
7 2
1 7
3 2
1 3
7 2
1 7
5 2
1 5
12 2
1 13
1 1
1 2
1 13
1
1 1
9
1 3
1 2
1 1
1 2
1 1
2 2
1 2
2 2
1 2
8
1 1
1 2
1 1
1 1
2 1
2 1
1 1
1 2
13
1 4
1 2
1 1
2 2
1 2
3 2
1 3
3 2
1 3
2 2
1 2
5 2
1 ...

result:

ok OK in maximum 0 operations

Test #4:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

6
3
1 3 2
3
3 1 2
3
1 2 3
3
2 3 1
3
2 1 3
3
3 2 1

output:

0
1
1 1
0
1
1 1
0
1
1 1

result:

ok OK in maximum 1 operations

Test #5:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

24
4
1 2 4 3
4
3 2 4 1
4
4 1 3 2
4
3 1 2 4
4
2 3 4 1
4
3 2 1 4
4
2 4 1 3
4
3 4 1 2
4
4 2 1 3
4
2 1 4 3
4
4 3 2 1
4
2 3 1 4
4
1 2 3 4
4
1 3 2 4
4
3 1 4 2
4
4 1 2 3
4
4 3 1 2
4
1 4 3 2
4
3 4 2 1
4
1 4 2 3
4
4 2 3 1
4
1 3 4 2
4
2 1 3 4
4
2 4 3 1

output:

5
1 1
2 1
2 1
1 1
1 2
6
1 1
1 1
2 1
2 1
1 1
1 2
4
2 1
1 1
1 2
1 1
2
2 1
1 1
3
1 1
1 2
1 1
5
1 2
1 2
1 1
1 2
1 1
3
1 2
1 2
1 1
6
1 2
1 1
2 1
2 1
1 1
1 2
6
1 2
1 2
1 2
1 1
1 2
1 2
6
2 1
1 1
1 2
1 1
1 2
1 1
6
1 1
1 2
1 2
1 1
1 2
1 2
8
1 2
1 2
1 1
1 1
2 1
2 1
1 1
1 2
0
5
1 2
1 2
1 1
1 2
1 2
9
2 1
1 1
1 ...

result:

ok OK in maximum 8 operations

Test #6:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

120
5
5 2 4 3 1
5
2 4 5 1 3
5
3 2 5 4 1
5
5 1 3 2 4
5
4 5 2 3 1
5
2 4 3 1 5
5
3 1 5 2 4
5
1 4 2 5 3
5
2 5 1 4 3
5
4 1 2 5 3
5
3 1 2 4 5
5
1 3 5 2 4
5
5 4 2 3 1
5
2 3 5 1 4
5
5 4 3 2 1
5
2 1 4 3 5
5
3 5 2 4 1
5
1 5 4 2 3
5
3 1 4 5 2
5
4 2 3 1 5
5
3 4 1 2 5
5
4 5 1 2 3
5
2 4 5 3 1
5
4 5 1 3 2
5
2 3 1 ...

output:

10
1 1
2 2
1 2
2 2
1 2
1 1
3 1
2 2
2 1
1 3
3
1 2
1 2
1 1
8
1 1
2 2
1 2
1 1
3 1
2 2
2 1
1 3
9
2 1
1 1
2 2
1 2
1 2
1 3
2 1
1 3
1 2
7
1 1
1 2
1 1
1 2
1 1
1 2
1 1
10
1 2
1 2
1 1
2 2
1 2
1 1
3 1
2 2
2 1
1 3
8
2 1
1 1
1 2
1 1
1 2
1 1
1 2
1 1
7
1 2
1 1
1 2
1 3
2 1
1 3
1 2
8
1 3
1 2
1 1
2 2
1 3
1 1
1 2
1 3
...

result:

ok OK in maximum 5 operations

Test #7:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

120
5
3 4 1 5 2
3
2 3 1
7
3 6 5 1 2 7 4
5
1 4 3 2 5
3
3 2 1
6
3 6 2 1 4 5
7
1 7 3 4 2 5 6
7
6 4 7 3 5 1 2
6
6 1 4 5 3 2
4
3 4 1 2
5
4 2 1 5 3
6
3 2 5 1 4 6
5
5 4 1 2 3
4
1 2 4 3
3
2 1 3
3
1 2 3
5
2 3 5 4 1
3
2 3 1
3
2 1 3
6
5 2 4 6 1 3
7
3 4 7 6 2 5 1
5
4 5 2 3 1
6
6 4 5 2 1 3
5
5 1 4 3 2
3
3 2 1
3
...

output:

7
1 3
1 2
1 1
2 2
1 2
1 2
1 1
1
1 1
9
1 4
2 2
1 2
3 2
1 3
4 2
1 4
3 2
1 3
6
2 2
1 2
1 2
1 1
2 2
1 2
1
1 1
5
1 3
1 2
1 1
1 2
1 1
10
1 2
1 1
1 2
1 1
1 2
1 1
2 2
1 2
2 2
1 2
12
1 2
2 2
1 2
2 2
1 2
2 2
1 2
3 2
1 5
2 1
1 3
1 4
13
2 1
1 1
1 2
1 1
3 2
1 3
2 2
1 2
1 1
4 1
2 3
3 1
1 4
6
1 2
1 1
2 1
2 1
1 1
1...

result:

ok OK in maximum 7 operations

Test #8:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

120
3
1 3 2
5
3 2 4 1 5
3
3 2 1
5
3 4 1 5 2
5
1 3 2 5 4
3
2 3 1
3
2 3 1
4
3 4 1 2
6
1 3 2 4 6 5
5
2 5 1 3 4
3
2 1 3
4
4 3 1 2
5
5 3 4 1 2
3
3 1 2
5
3 5 4 2 1
3
3 1 2
6
2 1 4 3 6 5
3
3 1 2
3
2 1 3
3
1 2 3
6
3 5 2 6 4 1
3
1 2 3
7
1 2 6 7 3 5 4
5
4 1 2 3 5
7
2 7 1 5 4 6 3
5
1 2 5 4 3
6
3 4 2 1 5 6
5
2 ...

output:

0
7
1 2
1 2
1 1
2 2
1 2
1 2
1 1
1
1 1
7
1 3
1 2
1 1
2 2
1 2
1 2
1 1
7
2 2
1 2
1 2
1 3
2 1
1 3
1 2
1
1 1
1
1 1
6
1 2
1 1
2 1
2 1
1 1
1 2
8
2 2
1 2
3 2
1 3
2 2
1 2
1 2
1 1
3
1 3
1 2
1 1
0
1
1 2
7
1 2
2 2
1 2
2 2
1 2
2 2
1 2
1
1 1
10
1 1
1 2
1 1
1 2
1 1
1 1
3 1
2 2
2 1
1 3
1
1 1
11
2 1
1 1
2 2
1 2
1 2
...

result:

ok OK in maximum 2 operations

Test #9:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

120
3
3 2 1
3
2 1 3
5
3 4 2 5 1
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 2
1 1
1 2
1 1
2 2
1 2
1 1
4 1
2 3
3 1
1 4
9
1 1
1 2
1 1
2 2
1 2
3 2
1 3
1 2
1 1
0
8
1 3
2 2
1 2
1 2
1 3
2 1
1 3
1 2
1
1 1
11
1 5
1 2
1 1
1 2
1 1
1 2
1 1
4 2
1 4
1 2
1 1
7
1 2
2 2
1 2
1 2
1 1
1 2
1 1
11
...

result:

ok OK in maximum 11 operations

Test #11:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

120
8
2 3 5 4 8 7 6 1
7
2 5 4 7 6 1 3
3
3 2 1
6
3 6 4 2 1 5
4
2 4 3 1
9
5 8 4 2 3 6 7 9 1
6
5 1 6 2 3 4
10
10 1 2 8 5 3 7 9 6 4
4
1 4 2 3
3
3 2 1
7
4 7 1 3 6 2 5
4
4 1 3 2
3
3 2 1
4
4 2 3 1
8
6 1 4 2 3 7 5 8
9
4 1 9 2 6 3 7 5 8
5
5 4 3 1 2
7
4 6 3 7 2 5 1
4
1 4 2 3
8
2 8 7 4 6 5 3 1
7
5 6 3 4 2 1 7
...

output:

13
1 1
1 2
1 1
3 2
1 3
4 2
1 4
5 2
1 5
3 2
1 3
4 2
1 4
11
1 2
1 2
1 1
3 2
1 3
4 2
1 4
3 2
1 3
4 2
1 4
1
1 1
7
1 2
1 2
1 1
1 2
1 1
3 2
1 3
8
1 1
1 2
1 1
1 1
2 1
2 1
1 1
1 2
15
1 1
1 2
1 1
3 2
1 3
2 2
1 2
2 2
1 2
1 2
1 1
1 2
1 1
3 2
1 3
10
2 1
1 1
1 2
1 1
2 2
1 2
1 2
1 1
1 2
1 1
18
2 1
1 1
2 2
1 2
3 2...

result:

ok OK in maximum 17 operations

Test #12:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

120
5
2 3 5 1 4
9
4 9 7 1 2 3 8 6 5
8
4 8 2 3 1 6 7 5
6
2 5 3 6 1 4
4
4 1 2 3
3
1 2 3
3
2 1 3
9
9 7 2 6 3 4 5 1 8
3
1 3 2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 4
12
1 2
1 1
3 2
1 3
1 2
1 1
5 2
1 5
1 2
1 1
2 2
1 2
0
7
1 2
2 2
1 2
2 2
1 2
2 2
1 2
1
1 1
10
1 2
1 1...

result:

ok OK in maximum 0 operations

Test #14:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

120
4
4 1 3 2
8
3 8 5 2 6 4 1 7
9
6 4 3 8 2 9 1 5 7
8
4 5 3 2 6 7 8 1
10
2 1 3 8 6 5 9 4 7 10
5
4 1 2 3 5
4
2 1 3 4
6
1 5 6 2 3 4
4
1 3 4 2
8
7 1 6 2 3 5 4 8
7
3 2 5 1 7 4 6
5
1 3 2 4 5
6
5 1 3 2 4 6
8
6 5 2 7 8 1 3 4
5
1 5 3 4 2
8
8 1 5 7 4 2 3 6
7
1 2 5 3 4 7 6
7
1 7 6 3 5 4 2
3
1 3 2
4
4 1 3 2
5
...

output:

4
2 1
1 1
1 2
1 1
11
1 2
1 2
1 1
2 2
1 2
3 2
1 3
1 2
1 1
4 2
1 4
15
1 3
2 2
1 2
3 2
1 3
1 2
1 1
4 2
1 4
2 2
1 2
3 2
1 3
6 2
1 6
13
1 1
1 2
1 1
3 2
1 3
3 2
1 3
3 2
1 3
1 2
1 1
2 2
1 2
18
2 1
1 1
2 2
1 2
1 2
1 1
3 2
1 3
3 2
1 3
5 2
1 5
4 2
1 4
5 2
1 5
7 2
1 7
8
2 1
1 1
2 2
1 2
2 2
1 2
2 2
1 2
7
2 1
1 ...

result:

ok OK in maximum 0 operations

Test #15:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

90
15
11 3 14 1 12 6 2 9 5 8 4 10 15 7 13
18
4 3 2 8 13 1 11 12 15 6 16 17 5 10 18 7 9 14
14
4 1 6 10 11 5 13 12 7 9 14 3 2 8
12
3 7 8 5 1 2 9 11 12 4 10 6
12
11 10 12 6 8 3 5 9 2 1 4 7
20
9 13 6 11 18 8 2 12 10 19 4 5 3 20 15 7 14 1 17 16
11
1 6 2 4 11 8 3 9 7 10 5
12
12 3 11 5 1 7 10 6 2 9 8 4
11
...

output:

27
1 12
1 2
1 1
3 2
1 3
1 2
1 1
4 2
1 4
2 2
1 2
7 2
1 7
3 2
1 3
2 2
1 2
4 2
1 4
3 2
1 3
6 2
1 6
1 2
1 1
5 2
1 5
33
1 13
1 2
1 1
3 2
1 3
2 2
1 2
1 2
1 1
2 2
1 2
7 2
1 7
5 2
1 5
4 2
1 4
10 2
1 10
7 2
1 7
4 2
1 4
12 2
1 12
12 2
1 12
5 2
1 5
13 2
1 13
11 2
1 11
26
2 1
1 1
2 2
1 2
1 2
1 1
1 2
1 1
2 2
1 2...

result:

ok OK in maximum 9 operations

Test #16:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

84
17
14 13 11 4 1 8 5 7 3 9 10 6 15 16 12 2 17
16
5 10 15 2 12 6 3 11 7 8 4 9 14 16 1 13
15
15 11 3 12 6 9 10 8 2 4 14 7 5 13 1
6
4 1 2 6 5 3
18
5 4 1 3 18 6 7 16 14 17 10 13 8 11 12 15 2 9
19
15 19 8 12 3 13 11 17 2 16 14 1 7 4 18 9 6 5 10
3
1 2 3
14
3 7 13 12 5 11 4 6 2 1 8 9 14 10
19
4 9 11 13 1...

output:

31
1 13
2 2
1 2
1 2
1 1
3 2
1 3
4 2
1 4
6 2
1 6
1 2
1 1
5 2
1 5
8 2
1 8
8 2
1 8
3 2
1 3
5 2
1 5
5 2
1 5
2 2
1 2
5 2
1 5
4 2
1 4
29
1 2
1 2
1 1
3 2
1 3
3 2
1 3
2 2
1 2
1 2
1 1
3 2
1 3
3 2
1 3
6 2
1 6
1 2
1 1
4 2
1 4
9 2
1 9
1 2
1 1
13 2
1 13
9 2
1 9
27
1 1
2 2
1 2
2 2
1 2
1 2
1 1
2 2
1 2
5 2
1 5
1 2
...

result:

ok OK in maximum 25 operations

Test #17:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

87
5
3 5 4 1 2
9
2 7 8 4 1 3 9 6 5
11
8 5 11 4 7 6 3 10 2 1 9
17
17 9 14 11 2 5 7 13 4 10 15 16 8 3 12 1 6
14
14 1 3 12 4 10 2 7 5 8 13 9 6 11
14
13 11 9 8 10 12 14 2 4 5 1 7 6 3
12
8 9 1 3 4 5 2 12 7 11 10 6
10
9 1 7 6 5 4 2 10 8 3
15
8 1 14 6 12 11 10 5 2 15 9 7 13 3 4
19
11 7 6 3 4 5 12 1 16 2 17...

output:

8
1 2
2 2
1 2
1 1
3 1
2 2
2 1
1 3
13
1 5
1 2
1 1
3 2
1 3
4 2
1 4
4 2
1 4
4 2
1 4
5 2
1 5
20
1 2
1 2
1 1
1 2
1 1
4 2
1 4
2 2
1 2
3 2
1 3
4 2
1 4
3 2
1 3
4 2
1 9
5 1
1 6
1 5
31
1 2
2 2
1 2
2 2
1 2
1 2
1 1
3 2
1 3
5 2
1 5
5 2
1 5
4 2
1 4
2 2
1 2
7 2
1 7
4 2
1 4
3 2
1 3
1 2
1 1
9 2
1 9
12 2
1 12
8 2
1 8...

result:

ok OK in maximum 15 operations

Test #18:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

90
9
8 9 3 6 7 5 1 2 4
10
6 9 3 7 1 2 5 8 10 4
11
8 9 1 5 7 2 3 4 6 10 11
18
11 18 2 3 7 17 16 12 1 8 9 4 5 15 13 14 6 10
7
3 5 7 6 4 1 2
13
5 2 3 10 11 4 8 13 1 9 12 7 6
12
7 1 11 12 6 4 5 10 8 3 9 2
10
4 2 8 1 5 3 10 9 7 6
20
5 17 13 14 2 12 4 18 8 20 7 10 6 15 1 16 19 11 3 9
5
2 5 4 1 3
6
6 4 3 2...

output:

16
1 3
2 2
1 2
2 2
1 2
3 2
1 3
3 2
1 3
2 2
1 2
3 2
1 7
4 1
1 5
1 4
17
1 6
2 2
1 2
3 2
1 3
2 2
1 2
5 2
1 5
3 2
1 3
7 2
1 7
6 2
1 6
4 2
1 4
19
1 9
2 2
1 2
3 2
1 3
4 2
1 4
4 2
1 4
2 2
1 2
1 2
1 1
1 2
1 1
1 2
1 1
6 2
1 6
33
1 10
2 2
1 2
3 2
1 3
4 2
1 4
5 2
1 5
1 2
1 1
1 2
1 1
1 2
1 1
9 2
1 9
5 2
1 5
3 2...

result:

ok OK in maximum 31 operations

Test #19:

score: -100
Runtime Error

input:

1
1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:


result: