-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ07008_DayConTangDan.java
58 lines (57 loc) · 1.43 KB
/
J07008_DayConTangDan.java
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
51
52
53
54
55
56
57
58
import java.util.*;
import java.io.*;
import java.math.*;
public class J07008_DayConTangDan {
public static int n;
public static int ok = 1;
public static int []a = new int[101];
public static int []b = new int[101];
public static void st()
{
for(int i = 0; i<=n;i++)
a[i] = 0;
}
public static void generate()
{
int i = n;
while(i>0 && a[i]==1)
a[i--]=0;
if(i==0) ok = 0;
else a[i] = 1;
}
public static boolean check()
{
Vector<Integer>v = new Vector<>();
for(int i = 1;i<=n;i++)
if(a[i]==1)
v.add(b[i]);
if(v.size()<2) return false;
for(int i = 0;i<v.size()-1;i++)
if(v.elementAt(i)>=v.elementAt(i+1))
return false;
return true;
}
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(new File("DAYSO.in"));
n = sc.nextInt();
for(int i = 1;i<=n;i++)
b[i] = sc.nextInt();
ArrayList<String>arr = new ArrayList<>();
st();
while(ok>0)
{
if(check())
{
String s ="";
for(int i = 1;i<=n;i++)
if(a[i]==1)
s+=String.valueOf(b[i])+" ";
arr.add(s);
}
generate();
}
Collections.sort(arr);
for(String s:arr)
System.out.println(s);
}
}