-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA02024.cpp
More file actions
44 lines (40 loc) · 829 Bytes
/
Copy pathDSA02024.cpp
File metadata and controls
44 lines (40 loc) · 829 Bytes
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
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int n;
int a[1000];
vector<int> tmp;
vector<string> ans;
void Try(int target, int pos)
{
for(int j = pos; j<=n; j++)
{
if(a[j] > target)
{
tmp.push_back(a[j]);
if(tmp.size()>=2)
{
string tmp1 = "";
for(int l : tmp)
{
tmp1 += to_string(l) + " ";
}
ans.push_back(tmp1);
}
Try(a[j], j+1);
tmp.pop_back();
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i<=n; i++)
cin >> a[i];
Try(-1, 1);
sort(ans.begin(), ans.end());
for(auto i : ans)
cout << i << endl;
}