QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397292#5305. Oscar is All You Need2745518585WA 1ms3896kbC++201.8kb2024-04-23 21:30:122024-04-23 21:30:14

Judging History

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

  • [2024-04-23 21:30:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3896kb
  • [2024-04-23 21:30:12]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1000001;
int n,a[N];
vector<pair<int,int>> ans;
void check(int x,int y)
{
    ans.push_back(make_pair(x,y));
    static int z[N];
    int q=0;
    for(int i=n-y+1;i<=n;++i) z[++q]=a[i];
    for(int i=x+1;i<=n-y;++i) z[++q]=a[i];
    for(int i=1;i<=x;++i) z[++q]=a[i];
    for(int i=1;i<=n;++i) a[i]=z[i];
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        ans.clear();
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&a[i]);
        }
        if(n==3)
        {
            if(a[1]>a[3]) check(1,1);
            printf("%d\n",ans.size());
            for(auto i:ans) printf("%d %d\n",i.first,i.second);
            continue;
        }
        int x=0;
        while(a[x]!=1) ++x;
        if(x==2) check(2,1),check(1,1);
        else if(x>2) check(1,n-x+1);
        for(int i=1;i<=n-3;++i)
        {
            int x=1;
            while(x+1<=i&&a[x+1]<a[n]) ++x;
            check(x,2),check(1,x);
        }
        // for(int i=1;i<=n;++i) printf("%d ",a[i]);printf("\n");
        if(a[n]==n)
        {
            int x=a[n-1];
            if(a[n-1]!=n-1) check(x-1,2),check(1,n-2),check(n-x-1,1),check(1,n-x),check(1,x);
        }
        else
        {
            for(int i=n-2;i<=n-1;++i)
            {
                int x=1;
                while(x+1<=i&&a[x+1]<a[n]) ++x;
                if(x<n-2) check(x,2),check(1,x);
                else if(x<n-1) check(1,1),check(n-2,1),check(2,n-3),check(n-3,1),check(1,n-2);
            }
        }
        printf("%d\n",ans.size());
        for(auto i:ans) printf("%d %d\n",i.first,i.second);
        // for(int i=1;i<=n;++i) printf("%d ",a[i]);printf("\n");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3896kb

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: 3828kb

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 Integer parameter [name=operations] equals to 28, violates the range [0, 27]