-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ07008
50 lines (46 loc) · 1.49 KB
/
J07008
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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Other/File.java to edit this template
*/
package withouclass;
import java.util.*;
import java.io.*;
public class J07008 {
static int n, a[] = new int[25];
static String k;
static Vector<Integer> x = new Vector<>();
static Vector<String> v = new Vector<>();
static Vector<Vector<Integer>> ans = new Vector<>();
static void Try(int posa) {
for (int i = posa + 1; i <= n; i++) {
if (a[i] > a[posa]) {
Vector<Integer> b = new Vector<>();
b.addAll(x);
b.add(a[i]);
x.add(a[i]);
if (x.size() > 1)
ans.add(b);
Try(i);
x.remove(x.size() - 1);
}
}
}
public static void main(String[] args) throws FileNotFoundException {
Scanner in = new Scanner(new File("DAYSO.in"));
n = in.nextInt();
a[0] = 0;
for (int i = 1; i <= n; i++)
a[i] = in.nextInt();
Try(0);
for (int i = 0; i < ans.size(); i++) {
k = "";
for (int j = 0; j < ans.get(i).size(); j++)
k += Integer.toString(ans.get(i).get(j)) + " ";
v.add(k);
}
Collections.sort(v);
for (int i = 0; i < v.size(); i++)
System.out.println(v.get(i));
in.close();
}
}