-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path1579B.cpp
50 lines (43 loc) · 882 Bytes
/
1579B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int arr[n];
for(int i = 0; i < n; i++){
cin>>arr[i];
}
int brr[n][3];
int k = 0;
for(int i = 1; i < n; i++){
int key = arr[i];
if(arr[i] < arr[i-1]){
int j = i - 1;
int count = 0;
while(arr[j] > key && j >= 0){
count++;
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = key;
brr[k][0] = i + 1;
brr[k][1] = j + 2;
brr[k][2] = count;
k++;
}
}
cout<<k<<endl;
for(int i = 0; i < k; i++){
cout<<brr[i][1]<<" "<<brr[i][0]<<" "<<brr[i][2]<<endl;
}
}
}