UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214269#2022. astawalr00ms516kbC++1.1kb2024-11-16 21:46:002024-11-16 23:13:45

answer

#include<cstdio>
using namespace std;
const int mn=32005;
int n;
int a[mn],b[mn];
bool fun()
{
    bool f=0;
    int strt=0;
    for(int i=1;i<=n;i++)
    {
        if(strt==0 || a[i]>a[i-1])
        {
            if(strt!=0 && a[strt]!=a[i-1])
            {
                printf("%d %d\n",strt,i-1);
                for(int j=strt;j<i;j++)
                {
                    b[j]=a[j];
                }
                for(int j=i-1;j>=strt;j--)
                {
                    a[i-1-j+strt]=b[j];
                }
                f=1;
            }
            strt=i;
            if(a[i]<=a[i-1])strt=i-1;
        }
    }
    if(strt!=0 && a[strt]!=a[n])
    {
        printf("%d %d\n",strt,n);
        f=1;
        for(int j=strt;j<=n;j++)
        {
            b[j]=a[j];
        }
        for(int j=n;j>=strt;j--)
        {
            a[n-j+strt]=b[j];
        }
    }
    return f;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    while(fun());
    // for(int i=1;i<=n;i++)
    // {
    //     printf("%d",a[i]);
    // }
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 512kb

input:

63
19732 30594 10113 7702 9784 6421 4697 13517 5317 8508 26509 15653 2986 31587 11246 12158 24378 49...

output:

2 4
4 7
7 9
9 10
10 13
14 15
15 16
16 18
18 19
19 21
21 23
23 25
25 26
26 28
28 31
31 35
35 36
36 39...

result:

wrong answer sequence hasn't been sorted

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 516kb

input:

197
10471 12679 10817 27406 21095 21068 9625 5396 14548 20977 29338 17674 30961 25672 4782 22715 301...

output:

2 3
4 8
8 9
9 10
11 12
13 15
15 16
16 18
18 22
22 23
23 24
24 25
25 28
28 29
29 30
30 33
33 35
35 36...

result:

wrong answer sequence hasn't been sorted

Subtask #3:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

29160
3 3 5 5 4 4 5 1 3 2 5 1 4 3 2 3 1 2 1 5 4 4 4 0 2 3 4 2 1 4 4 5 3 3 5 4 2 4 4 1 3 5 1 1 2 2 2 ...

output:

3 6
6 8
8 10
10 12
12 15
15 17
17 19
19 24
24 25
25 26
26 29
29 31
31 34
34 37
37 40
40 41
41 44
44 ...

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #16:

score: 0
Time Limit Exceeded

input:

25162
6548 134 11176 15393 24121 2053 29582 27616 22505 27930 3608 3082 22087 20841 5912 29959 21750...

output:

1 2
5 6
7 9
9 12
12 15
16 18
18 19
20 22
23 25
25 27
27 30
30 31
31 34
34 35
35 38
38 40
40 41
41 46...

result: