UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214240#2022. atonysun05300808ms4848kbC++795b2024-11-16 19:30:172024-11-16 23:11:31

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define int long long

using namespace std;

const int N = 1e5 + 10;

int n;
int a[N];
map<int, int> hash1;
int idx;
pair<int, int> ans[N];

signed main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i ++ ) cin >> a[i];
    for(int i = 1 ; i <= n ; i ++ ) hash1[a[i]] = i;
    for(int i = 1 ; i <= n ; i ++ )
        if(a[i] != i)
        {
            int l = i;
            int r = hash1[i];
            for(int j = l ; j <= (r + l) / 2 ; j ++ ) swap(a[j], a[r - j + l]);
            for(int j = l ; j <= r ; j ++ ) hash1[a[i]] = i;
            ans[ ++ idx] = {l, r};
        }
    cout << idx << endl;
    for(int i = 1 ; i <= idx ; i ++ ) cout << ans[i].x << " " << ans[i].y << endl;
    return 0;
}

Details

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

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

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

output:

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

result:

wrong answer Integer parameter [name=ri] equals to 0, violates the range [1, 63]

Subtask #2:

score: 0
Wrong Answer

Test #6:

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

input:

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

output:

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

result:

wrong answer Integer parameter [name=ri] equals to 0, violates the range [1, 197]

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 36ms
memory: 4848kb

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:

29160
1 29158
2 29160
3 29151
4 29157
5 3
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18...

result:

FAIL l<=r

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 772ms
memory: 4808kb

input:

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

output:

25162
1 0
2 0
3 10772
4 0
5 0
6 0
7 0
8 0
9 20392
10 13682
11 0
12 20268
13 0
14 0
15 19776
16 12369...

result:

wrong answer Integer parameter [name=ri] equals to 0, violates the range [1, 25162]