File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,28 @@ public class _15652 {
14
14
public static void main (String [] args ) throws IOException {
15
15
BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
16
16
StringTokenizer st = new StringTokenizer (br .readLine ());
17
- // memory 111924 runtime 372
17
+ // memory 13464 runtime 92
18
18
N = Integer .parseInt (st .nextToken ());
19
19
M = Integer .parseInt (st .nextToken ());
20
+ arr = new int [M ];
21
+ dfs (1 ,0 );
22
+ System .out .println (sb );
23
+ }
20
24
25
+ static void dfs (int current , int depth ){
21
26
27
+ if (depth == M ){
28
+ for (int v : arr ){
29
+ sb .append (v ).append (" " );
30
+ }
31
+ sb .append ("\n " );
32
+ return ;
33
+ }
22
34
23
-
35
+ for (int i =current ; i <=N ; i ++){
36
+ arr [depth ] = i ;
37
+ dfs (i , depth +1 );
38
+ }
24
39
}
25
40
}
26
41
/*
You can’t perform that action at this time.
0 commit comments