8000 update 15664.cpp · unluckyjung/basic-algo-lecture@9f01d5a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f01d5a

Browse files
committed
update 15664.cpp
1 parent 3fcca99 commit 9f01d5a

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

0x0C/solutions/15664.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
// Authored by : BaaaaaaaaaaarkingDog
2-
// Co-authored by : -
2+
// Co-authored by : - connieya
33
// http://boj.kr/****************
44
#include <bits/stdc++.h>
55
using namespace std;
66

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);
1141
}

0 commit comments

Comments
 (0)
0