QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#784 | #529114 | #7902. Strange Sorting | liyelin | Max_FWL | Failed. | 2024-08-24 15:04:13 | 2024-08-24 15:04:13 |
Details
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 | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}