ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214276 | #2022. a | Filberte | 20 | 50ms | 1844kb | C++11 | 748b | 2024-11-16 22:25:02 | 2024-11-16 23:14:30 |
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 32500;
int n, a[N];
bool ok(){
for(int i = 2;i <= n;i++) if(a[i] < a[i - 1]) return 0;
return 1;
}
vector<pair<int, int>> ans;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
while(!ok()){
for(int l = 1, r;l < n;l = r + 1){
r = l;
while(a[r + 1] <= a[r] && r < n) r++;
if(l < r){
ans.push_back({l, r});
reverse(a + l, a + r + 1);
}
}
}
cout << (int)ans.size() << endl;
for(pair<int, int> op : ans)
cout << op.first << " " << op.second << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 0ms
memory: 1276kb
input:
63 19732 30594 10113 7702 9784 6421 4697 13517 5317 8508 26509 15653 2986 31587 11246 12158 24378 49...
output:
757 2 4 5 7 8 9 11 13 14 15 17 18 20 21 22 23 24 25 27 28 29 31 32 35 37 39 40 41 42 43 44 47 49 50 ...
result:
ok ok,using 1583 times
Test #2:
score: 0
Accepted
time: 0ms
memory: 1256kb
input:
25 21264 13876 11861 12802 18452 3136 17660 21163 14140 20632 25998 22051 10612 12680 7873 23249 274...
output:
117 1 3 5 6 8 9 11 13 14 15 18 19 20 23 24 25 3 5 6 8 9 11 13 14 17 18 19 20 23 24 2 3 5 6 8 9 12 13...
result:
ok ok,using 242 times
Test #3:
score: 0
Accepted
time: 3ms
memory: 1316kb
input:
95 26373 31391 7777 12225 25301 24166 2461 4926 15751 18727 29175 18511 17455 16025 16845 6723 3477 ...
output:
2191 2 3 5 7 11 14 15 17 18 19 22 23 25 26 29 31 32 33 35 36 37 38 40 41 42 43 44 45 46 48 49 50 52 ...
result:
ok ok,using 4564 times
Test #4:
score: 0
Accepted
time: 4ms
memory: 1316kb
input:
100 15104 1621 22502 12704 13109 9592 1390 22280 23468 26863 23084 10981 20492 7842 12883 16636 2565...
output:
2215 1 2 3 4 5 7 10 12 13 14 17 18 19 20 21 22 23 25 27 28 29 31 32 35 37 38 39 42 44 46 47 49 52 54...
result:
ok ok,using 4564 times
Test #5:
score: 0
Accepted
time: 2ms
memory: 1312kb
input:
100 13822 19801 16537 25492 24250 30303 18588 13044 8538 23642 864 10878 16671 5509 13062 15457 2577...
output:
2345 2 3 4 5 6 9 10 11 13 14 17 18 21 24 25 26 28 30 33 34 35 36 39 40 41 42 43 44 45 46 47 50 52 54...
result:
ok ok,using 4764 times
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 40
Accepted
time: 0ms
memory: 1396kb
input:
197 10471 12679 10817 27406 21095 21068 9625 5396 14548 20977 29338 17674 30961 25672 4782 22715 301...
output:
8309 2 3 4 8 11 12 13 15 17 18 19 22 26 28 31 33 34 35 37 38 40 41 43 44 45 49 51 52 53 54 57 62 64 ...
result:
ok ok,using 17284 times
Test #7:
score: 0
Accepted
time: 20ms
memory: 1456kb
input:
354 28133 31628 5619 8961 1003 9779 27591 14336 31618 17755 6349 17570 25604 24107 23136 21537 16494...
output:
28223 2 3 4 5 7 8 9 11 13 17 18 21 22 24 25 26 27 29 32 33 36 37 38 40 41 42 44 45 46 47 48 49 50 53...
result:
ok ok,using 57864 times
Test #8:
score: 0
Accepted
time: 21ms
memory: 1844kb
input:
512 14563 17808 18597 4341 12143 30490 13558 4331 30512 15302 14593 3642 21783 21775 23315 5766 1661...
output:
63674 3 4 6 8 9 12 13 14 15 16 17 18 19 20 23 27 29 31 32 33 34 35 37 39 41 42 43 45 46 48 49 50 51 ...
result:
ok ok,using 130265 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:
242080 3 4 5 6 8 10 11 13 14 15 16 17 18 22 24 25 26 27 30 32 34 35 36 37 39 40 41 43 44 46 47 51 52...
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...