forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6603_1.cpp
More file actions
53 lines (48 loc) · 910 Bytes
/
6603_1.cpp
File metadata and controls
53 lines (48 loc) · 910 Bytes
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
// Authored by : yongjunleeme
// Co-authored by : -
// http://boj.kr/54ced2c7e27e40da93c95a150d93d56e
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[15];
int num[15];
bool isused[15];
void func(int k){
if(k == 6){
bool flag = true;
int tmp = -1;
for(int i = 0; i < 6; i++){
if(tmp > num[arr[i]]) flag = false;
tmp = num[arr[i]];
}
if(flag){
for(int i = 0; i < 6; i++)
cout << num[arr[i]] << " ";
cout << "\n";
}
return;
}
for(int i = 0; i < n; i++){
if(!isused[i]){
arr[k] = i;
isused[i] = 1;
func(k+1);
isused[i] = 0;
}
}
}
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
while(1){
cin >> n;
if(n == 0) break;
for(int i = 0; i < n; i++)
cin >> num[i];
sort(num, num+n);
func(0);
cout << "\n";
fill(num, num+n, 0);
fill(arr, arr+n, 0);
}
}