QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#784 | #529114 | #7902. Strange Sorting | liyelin | Max_FWL | Failed. | 2024-08-24 15:04:13 | 2024-08-24 15:04:13 |
详细
Extra Test:
Accepted
time: 0ms
memory: 3704kb
input:
1 5 3 5 4 2 1
output:
1 1 5
result:
ok ok 1 Test Cases. (1 test case)
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#529114 | #7902. Strange Sorting | Max_FWL | AC ✓ | 3ms | 3732kb | C++14 | 758b | 2024-08-24 09:34:16 | 2024-08-24 09:34:17 |
answer
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef pair<int, int> pii;
const int N = 110;
int T, n, a[N], t[N];
vector<pii> ans;
void Solve(){
ans.clear();
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
t[i] = a[i];
}
sort(t + 1, t + n + 1);
for (int i = n; i >= 1; i--)
if (a[i] ^ t[i]){
for (int j = 1; j < i; j++)
if (a[j] > a[i]){
sort(a + j, a + i + 1);
ans.push_back(mp(j, i));
break;
}
}
cout << ans.size() << endl;
for (auto e : ans){
int l, r;
tie(l, r) = e;
cout << l << " " << r << endl;
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--)
Solve();
return 0;
}