QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#187288#5305. Oscar is All You NeedfstqwqRE 2ms4104kbC++142.7kb2023-09-24 16:06:002023-09-24 16:06:01

Judging History

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

  • [2023-09-24 16:06:01]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:4104kb
  • [2023-09-24 16:06:00]
  • 提交

answer

#include<bits/stdc++.h>
#define N 1100
using namespace std;
typedef vector<int> VI;
typedef pair<int,int> PII;
vector<VI> a,b;
PII ans[N];int top;
int n,bel[N];
void oper(int x,int y,int type=0){
    b=a;int sx=0,sy=0;a.clear();
    for(int i=x+y;i<b.size();i++)a.push_back(b[i]);
    for(int i=x;i<x+y;i++)a.push_back(b[i]),sy+=b[i].size();
    for(int i=0;i<x;i++)a.push_back(b[i]),sx+=b[i].size();
    if(type)top--;
    else ans[++top]=make_pair(sx,n-sy-sx);
}
VI ls;
void init(){
    b=a;a.clear();
    for(int i=0;i<b.size();i++){
        int j=i;
        while(j+1<b.size() && b[j+1][0]==b[j][0]+b[j].size())j++;
        ls.clear();
        for(int k=i;k<=j;k++){
            for(auto x:b[k])ls.push_back(x);
        }
        i=j;
        a.push_back(ls);
    }
}
void finit(){
    b=a;a.clear();
    int cnt=4-b.size();
    for(auto x:b){
        int i=0;
        for(;i+1<x.size() && cnt;i++,cnt--){
            ls.clear();ls.push_back(x[i]);
            a.push_back(ls);
        }
        ls.clear();
        for(;i<x.size();i++)ls.push_back(x[i]);
        a.push_back(ls);
    }
    // for(auto x:a){
    //     for(auto y:x)printf("%d ",y);
    //     printf("\n");
    // }
}
void solve(){
    int len=a.size();memset(bel,0,sizeof(bel));
    for(int i=0;i<len;i++)bel[a[i][0]]=i;
    for(int i=0;i+1<len;i++){
        if(a[i][0]+a[i].size()>n)continue;
        int x=bel[a[i][0]+a[i].size()];
        if(x>i+2){
            oper(i+1,x-2-i);
            oper(1,len-2);
            return ;
        }
        if(i && x==i+2){
            oper(i,2);
            oper(len-x,1);
            return ;
        }
    }
    oper(len-2,1);
}
bool check(){
    for(int i=0;i<3;i++){
        if(a[i][0]>a[i+1][0])return 0;
    }
    return 1;
}
bool dfs(int dep){
    if(check())return 1;
    if(dep>7)return 0;
    for(int i=1;i<=2;i++){
        for(int j=1;i+j<=3;j++){
            oper(i,j);
            if(dfs(dep+1)==1)return 1;
            oper(4-i-j,j,1);
        }
    }
    return 0;
}
int main(){
    int T;scanf("%d",&T);
    while(T--){
        top=0;a.clear();b.clear();
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            int x;scanf("%d",&x);
            ls.clear();ls.push_back(x);
            a.push_back(ls);
        }
        if(n==3){
            if(a[0][0]>a[2][0])printf("1\n1 1\n");
            else printf("0\n");
            continue;
        }
        init();
        while(a.size()>4){
            solve();
            init();
        }
        finit();
        dfs(1);
        printf("%d\n",top);
        for(int i=1;i<=top;i++)printf("%d %d\n",ans[i].first,ans[i].second);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
1 3 2
5
4 1 2 3 5

output:

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

result:

ok OK in maximum 6 operations

Test #2:

score: 0
Accepted
time: 2ms
memory: 3764kb

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
21
1 2
1 1
3 7
1 1
2 4
1 2
5 6
1 1
3 8
1 1
8 3
2 1
2 6
4 2
5 5
1 7
2 5
4 2
2 9
5 2
6 5
67
1 22
1 1
2 28
1 2
3 32
1 3
4 3
1 4
5 12
1 5
6 13
1 6
7 26
1 7
8 18
1 8
9 8
1 9
10 11
1 10
11 13
1 11
12 17
1 12
14 13
1 1
2 23
1 2
3 29
1 3
4 14
1 4
5 21
1 5
6 16
1 6
7 25
1 7
8 2
1 8
9 25
1 9
1...

result:

ok OK in maximum 1 operations

Test #3:

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

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:

11
1 4
4 2
1 6
4 1
2 5
1 3
1 5
4 3
2 5
1 3
1 1
24
1 10
1 1
3 9
1 1
2 11
1 2
3 6
2 3
4 9
1 4
6 5
2 1
3 10
1 1
10 3
2 2
3 8
6 3
1 8
2 7
6 8
6 7
1 6
6 3
1
1 1
8
1 3
1 1
4 2
1 6
2 1
1 3
1 5
4 1
6
1 2
1 2
1 1
1 2
1 1
2 1
14
1 2
1 1
2 5
1 2
3 3
1 3
4 2
1 4
1 2
1 6
5 2
1 6
1 1
1 2
7
2 2
1 3
1 2
1 3
2 2
1 2...

result:

ok OK in maximum 0 operations

Test #4:

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

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: 1ms
memory: 4092kb

input:

24
4
1 2 4 3
4
3 2 4 1
4
4 1 3 2
4
3 1 2 4
4
2 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
2 1
9
1 2
1 1
2 2
1 3
1 2
1 3
2 1
1 3
1 2
4
1 2
2 2
1 3
2 2
9
1 2
1 1
2 2
1 3
1 2
1 3
2 2
1 3
1 1
7
1 2
1 3
2 2
1 3
1 1
1 2
1 3
6
1 ...

result:

ok OK in maximum 9 operations

Test #7:

score: 0
Accepted
time: 2ms
memory: 3808kb

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

result:

ok OK in maximum 8 operations

Test #8:

score: 0
Accepted
time: 2ms
memory: 3896kb

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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3
3 2
1 5
3 2
1 5
5 1
1 3
3 3
11
1 2
1 1
3 2
1 3
4 2
1...

result:

ok OK in maximum 8 operations

Test #10:

score: 0
Accepted
time: 2ms
memory: 3852kb

input:

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

output:

7
1 2
1 3
2 2
1 3
1 1
1 2
1 3
4
1 2
1 1
3 2
1 5
10
1 3
1 1
2 2
1 2
3 2
1 4
1 1
1 2
1 4
3 1
11
1 3
1 1
2 2
1 2
3 2
1 4
1 2
1 4
3 1
1 4
1 2
0
6
2 2
1 3
1 2
1 1
1 3
2 1
1
1 1
7
1 3
1 1
2 3
1 2
1 4
3 3
2 4
6
2 2
1 4
2 2
1 2
2 3
2 3
6
1 3
1 2
1 3
2 2
2 2
2 1
10
2 4
1 1
2 2
1 2
4 2
1 5
1 1
1 2
1 5
4 1
5
1...

result:

ok OK in maximum 6 operations

Test #11:

score: 0
Accepted
time: 2ms
memory: 3812kb

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:

12
3 3
1 1
2 3
2 2
3 4
1 3
4 2
1 6
2 2
1 2
2 5
4 3
12
1 2
1 1
3 3
1 1
2 3
2 2
3 3
1 4
1 3
2 1
1 5
3 1
1
1 1
8
3 2
1 1
2 2
1 4
2 2
2 2
2 1
1 3
6
1 2
1 2
1 1
1 2
1 1
2 1
12
1 6
2 1
3 5
1 3
4 4
2 4
5 3
1 6
1 3
2 1
1 7
5 1
7
1 4
1 2
1 4
3 2
1 3
3 2
1 4
17
3 6
1 2
3 5
1 3
4 5
1 4
5 4
1 5
6 3
1 6
7 2
1 8
...

result:

ok OK in maximum 15 operations

Test #12:

score: 0
Accepted
time: 2ms
memory: 3808kb

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

output:

7
2 2
1 3
1 2
1 3
2 2
1 3
1 1
13
1 2
1 1
2 2
1 2
4 1
1 7
1 3
1 6
5 3
2 5
5 3
1 6
1 1
7
1 3
2 1
2 3
1 2
1 3
2 5
4 3
10
1 3
3 2
1 2
1 1
2 3
2 3
1 3
3 1
1 2
2 2
7
1 2
1 2
1 2
1 2
1 2
1 1
1 2
0
0
10
2 2
1 1
2 5
3 2
3 4
1 5
2 4
3 2
2 6
3 2
0
13
1 4
1 1
2 2
1 2
4 1
1 6
1 3
1 5
4 3
2 4
4 3
1 5
1 1
11
1 3
1...

result:

ok OK in maximum 1 operations

Test #13:

score: 0
Accepted
time: 2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4
3 3
3 4
1 3
6 1
15
1 2
1 1
2 6
1 2
4 2
1 1
2 5
4 2
3 5
1 4
1 5
4 4
3 5
1 4
1 1
8
2 5
1 2
5 2
1 6
1 2
1 1
1 6
5 1
16
3 4
1 1
2 5
1 2
3 2
1 3
4 4
1 4
7 2
1 1
2 2
1 8
6 2
2 6
6 1
1 7
6
1 3
2 2
1 3
1 2
2 1
1 1
7
1 2
1 2
1 1
1 2
1 2
1 1
1 2...

result:

ok OK in maximum 0 operations

Test #15:

score: 0
Accepted
time: 2ms
memory: 3820kb

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:

26
1 12
1 1
2 5
1 2
4 5
1 1
2 6
1 2
3 4
1 3
4 4
1 4
5 6
3 5
6 6
2 6
10 4
1 3
4 8
7 4
5 8
1 7
2 8
7 2
2 12
5 2
26
1 8
2 1
2 4
1 2
3 12
1 3
4 11
1 4
5 5
1 5
6 5
3 6
7 6
1 7
9 3
1 9
10 7
4 10
11 5
1 11
15 2
1 16
1 1
1 2
1 16
15 1
24
1 11
2 1
2 4
1 2
3 8
1 3
4 7
1 4
5 5
1 5
6 5
1 6
8 4
4 9
12 1
2 3
2 2
...

result:

ok OK in maximum 5 operations

Test #16:

score: 0
Accepted
time: 2ms
memory: 3816kb

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:

24
1 6
1 1
3 13
1 3
6 3
1 1
2 6
4 2
3 6
2 3
8 5
1 1
2 10
1 2
3 6
1 3
5 10
1 5
13 2
2 14
1 4
1 1
3 13
12 4
27
1 12
1 1
2 13
1 2
6 7
1 1
2 11
1 2
3 3
1 3
4 4
1 4
5 10
2 5
6 4
1 6
9 5
4 2
3 11
7 3
7 8
1 8
1 8
7 8
7 8
1 8
1 1
27
1 12
12 2
1 7
1 1
2 12
1 2
3 9
2 3
4 7
1 4
5 5
2 5
6 4
2 6
8 3
1 8
10 4
1 1...

result:

ok OK in maximum 12 operations

Test #17:

score: 0
Accepted
time: 2ms
memory: 3836kb

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:

6
1 3
1 2
1 1
1 3
2 1
2 2
14
1 5
1 1
2 4
2 2
3 4
1 3
4 2
1 4
1 2
1 7
6 2
1 7
1 1
1 2
19
1 2
1 1
2 4
1 2
3 6
1 3
5 2
1 1
3 6
1 1
6 4
3 1
1 9
6 2
1 9
3 1
1 4
1 7
6 1
25
2 9
1 1
2 8
1 2
3 5
1 3
4 8
1 4
5 5
1 5
6 7
1 6
8 3
1 8
10 3
1 1
2 12
1 2
3 5
1 3
5 11
1 5
1 3
2 14
13 3
18
2 9
1 1
2 6
1 2
4 5
1 1
2...

result:

ok OK in maximum 10 operations

Test #18:

score: 0
Accepted
time: 2ms
memory: 3816kb

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:

10
3 3
2 1
2 4
4 3
1 6
4 3
2 6
6 2
2 4
4 4
16
1 8
1 1
2 6
1 2
3 6
1 3
4 3
1 4
6 3
2 1
2 7
5 3
1 7
7 1
1 5
5 3
13
2 3
1 2
5 5
1 1
5 5
4 1
2 8
4 3
1 8
4 3
2 8
4 2
6 4
24
1 12
1 1
2 11
1 2
4 3
2 4
5 7
1 5
6 2
1 6
7 5
1 7
10 6
2 2
6 11
1 1
12 1
6 3
2 15
9 3
1 15
15 1
1 9
9 7
10
1 4
1 1
4 1
1 5
1 4
2 3
2...

result:

ok OK in maximum 26 operations

Test #19:

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

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:

0

result:

ok OK in maximum 0 operations

Test #20:

score: -100
Runtime Error

input:

1
1000
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 ...

output:


result: