UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214246#2022. aLin_ziluo028ms1480kbC++11490b2024-11-16 20:10:422024-11-16 23:12:05

answer

#include <bits/stdc++.h>
using namespace std;
int a[32010];
vector<pair<int,int>> ans;
int main(){
	int n;
	cin >> n;
	for (int i = 1;i <= n;i++)	
		cin >> a[i];
	a[n + 1] = INT_MAX;
	int i = 1;
	while (i < n){
		if (a[i] > a[i + 1]){
			int j = i + 1;
			while (a[j] > a[j + 1])
				j++;
			reverse(a + i,a + j + 1);
			ans.emplace_back(i,j);
		}
		i++;
	}
	cout << ans.size() << endl;
	for (auto i : ans)
		cout << i.first << ' ' << i.second << endl;
	return 0;
}

Details

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

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

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

output:

31
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...

result:

wrong answer sequence hasn't been sorted

Subtask #2:

score: 0
Wrong Answer

Test #6:

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

input:

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

output:

97
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...

result:

wrong answer sequence hasn't been sorted

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 10ms
memory: 1480kb

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:

16203
4 5
5 6
7 8
8 10
11 12
12 15
15 17
17 19
20 21
21 22
22 24
24 25
25 26
26 29
29 30
30 31
32 33...

result:

wrong answer sequence hasn't been sorted

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 18ms
memory: 1460kb

input:

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

output:

12557
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...

result:

wrong answer sequence hasn't been sorted