ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214238 | #2022. a | Lin_ziluo | 20 | 103ms | 1696kb | C++11 | 522b | 2024-11-16 19:20:30 | 2024-11-16 23:11:17 |
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;
while (!is_sorted(a + 1,a + n + 1))
for (int i = 1;i < n;i++)
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);
}
cout << ans.size() << endl;
for (auto i : ans)
cout << i.first << ' ' << i.second << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 0ms
memory: 1256kb
input:
63 19732 30594 10113 7702 9784 6421 4697 13517 5317 8508 26509 15653 2986 31587 11246 12158 24378 49...
output:
632 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 3...
result:
ok ok,using 1385 times
Test #2:
score: 0
Accepted
time: 0ms
memory: 1240kb
input:
25 21264 13876 11861 12802 18452 3136 17660 21163 14140 20632 25998 22051 10612 12680 7873 23249 274...
output:
105 1 3 3 4 4 6 6 7 7 9 9 10 11 13 13 15 15 16 18 19 19 23 23 25 2 4 5 7 8 9 10 11 12 13 13 14 17 19...
result:
ok ok,using 223 times
Test #3:
score: 0
Accepted
time: 0ms
memory: 1272kb
input:
95 26373 31391 7777 12225 25301 24166 2461 4926 15751 18727 29175 18511 17455 16025 16845 6723 3477 ...
output:
2025 2 3 3 4 4 7 7 8 8 9 9 10 10 14 14 17 17 19 19 20 20 21 22 23 23 24 24 26 26 27 27 28 28 31 31 3...
result:
ok ok,using 4299 times
Test #4:
score: 0
Accepted
time: 0ms
memory: 1276kb
input:
100 15104 1621 22502 12704 13109 9592 1390 22280 23468 26863 23084 10981 20492 7842 12883 16636 2565...
output:
1943 1 2 3 4 4 7 7 8 10 12 12 14 14 15 15 16 16 18 19 20 20 22 22 25 25 26 27 28 28 31 31 35 35 36 3...
result:
ok ok,using 4134 times
Test #5:
score: 0
Accepted
time: 3ms
memory: 1276kb
input:
100 13822 19801 16537 25492 24250 30303 18588 13044 8538 23642 864 10878 16671 5509 13062 15457 2577...
output:
1974 2 3 4 5 6 9 9 11 11 12 12 14 14 15 15 16 16 18 18 19 19 20 20 24 24 26 26 27 27 30 30 31 31 32 ...
result:
ok ok,using 4199 times
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 40
Accepted
time: 10ms
memory: 1364kb
input:
197 10471 12679 10817 27406 21095 21068 9625 5396 14548 20977 29338 17674 30961 25672 4782 22715 301...
output:
7633 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 ...
result:
ok ok,using 16208 times
Test #7:
score: 0
Accepted
time: 26ms
memory: 1440kb
input:
354 28133 31628 5619 8961 1003 9779 27591 14336 31618 17755 6349 17570 25604 24107 23136 21537 16494...
output:
25420 2 3 3 5 5 6 6 8 8 11 11 12 12 17 17 21 21 24 24 26 26 29 29 30 30 31 31 33 33 34 34 35 35 37 3...
result:
ok ok,using 53525 times
Test #8:
score: 0
Accepted
time: 64ms
memory: 1696kb
input:
512 14563 17808 18597 4341 12143 30490 13558 4331 30512 15302 14593 3642 21783 21775 23315 5766 1661...
output:
58105 3 4 4 5 6 8 9 12 12 14 14 16 16 18 19 20 20 21 21 22 22 27 27 28 28 31 31 33 33 35 35 36 36 39...
result:
ok ok,using 121381 times
Test #9:
score: -40
Time Limit Exceeded
input:
1000 1502 12015 26522 985 16804 3210 22284 28860 17265 9237 23503 15006 9625 30582 12808 25544 5298 ...
output:
232989 3 4 4 6 6 7 8 10 10 13 14 15 15 17 17 22 22 23 23 25 25 27 27 28 28 29 29 32 32 33 33 35 35 3...
result:
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:
result:
Subtask #4:
score: 0
Memory Limit Exceeded
Test #16:
score: 0
Memory Limit Exceeded
input:
25162 6548 134 11176 15393 24121 2053 29582 27616 22505 27930 3608 3082 22087 20841 5912 29959 21750...