File tree Expand file tree Collapse file tree 1 file changed +35
-5
lines changed Expand file tree Collapse file tree 1 file changed +35
-5
lines changed Original file line number Diff line number Diff line change 1
1
// Authored by : BaaaaaaaaaaarkingDog
2
- // Co-authored by : -
2
+ // Co-authored by : - connieya
3
3
// http://boj.kr/****************
4
4
#include < bits/stdc++.h>
5
5
using namespace std ;
6
6
7
- int main (void ){
8
- ios::sync_with_stdio (0 );
9
- cin.tie (0 );
10
-
7
+ int n, m;
8
+ int arr[10 ];
9
+ int num[10 ];
10
+ bool visited[10 ];
11
+
12
+ void func (int L , int start) {
13
+ if (L == m) {
14
+ for (int i = 0 ; i < m; ++i) {
15
+ cout << arr[i] << ' ' ;
16
+ }
17
+ cout << ' \n ' ;
18
+ return ;
19
+ }
20
+ int tmp =0 ;
21
+ for (int i = start; i < n; ++i) {
22
+ if (!visited[i] && tmp != num[i]){
23
+ visited[i] = true ;
24
+ arr[L] = num[i];
25
+ tmp = arr[L];
26
+ func (L + 1 , i);
27
+ visited[i] = false ;
28
+ }
29
+ }
30
+ }
31
+
32
+ int main (void ) {
33
+ ios::sync_with_stdio (0 );
34
+ cin.tie (0 );
35
+ cin >> n >> m;
36
+ for (int i = 0 ; i < n; ++i) {
37
+ cin >> num[i];
38
+ }
39
+ sort (num, num + n);
40
+ func (0 ,0 );
11
41
}
You can’t perform that action at this time.
0 commit comments