File tree Expand file tree Collapse file tree 1 file changed +17
-39
lines changed Expand file tree Collapse file tree 1 file changed +17
-39
lines changed Original file line number Diff line number Diff line change 1
- // Authored by : yongjunleeme
1
+ // Authored by : qwee158
2
2
// Co-authored by : -
3
- // http://boj.kr/54ced2c7e27e40da93c95a150d93d56e
3
+ // http://boj.kr/091a628889c24cd79d04dd2abe6e8b5d
4
4
#include < bits/stdc++.h>
5
5
using namespace std ;
6
6
7
- int n;
8
- int arr[15 ];
9
- int num[15 ];
10
- bool isused[15 ];
7
+ int k, input[20 ], arr[10 ];
11
8
12
- void func (int k){
13
- if (k == 6 ){
14
- bool flag = true ;
15
- int tmp = -1 ;
16
- for (int i = 0 ; i < 6 ; i++){
17
- if (tmp > num[arr[i]]) flag = false ;
18
- tmp = num[arr[i]];
19
- }
20
-
21
- if (flag){
22
- for (int i = 0 ; i < 6 ; i++)
23
- cout << num[arr[i]] << " " ;
24
- cout << " \n " ;
25
- }
9
+ void func (int cnt, int cur) {
10
+ if (cnt == 6 ) {
11
+ for (int i = 0 ; i < 6 ; i++) cout << arr[i] << ' ' ;
12
+ cout << ' \n ' ;
26
13
return ;
27
14
}
28
- for (int i = 0 ; i < n; i++){
29
- if (!isused[i]){
30
- arr[k] = i;
31
- isused[i] = 1 ;
32
- func (k+1 );
33
- isused[i] = 0 ;
34
- }
15
+ for (int i = cur; i < k; i++) {
16
+ arr[cnt] = input[i];
17
+ func (cnt + 1 , i + 1 );
35
18
}
36
19
}
37
20
38
- int main (void ){
21
+ int main (void ) {
39
22
ios::sync_with_stdio (0 );
40
23
cin.tie (0 );
41
-
42
- while (1 ){
43
- cin >> n;
44
- if (n == 0 ) break ;
45
- for (int i = 0 ; i < n; i++)
46
- cin >> num[i];
47
- sort (num, num+n);
48
- func (0 );
49
- cout << " \n " ;
50
- fill (num, num+n, 0 );
51
- fill (arr, arr+n, 0 );
24
+ while (1 ) {
25
+ cin >> k;
26
+ if (k == 0 ) break ;
27
+ for (int i = 0 ; i < k; i++) cin >> input[i];
28
+ func (0 , 0 );
29
+ cout << ' \n ' ;
52
30
}
53
31
}
You can’t perform that action at this time.
0 commit comments