-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4468_카드놓기.cpp
52 lines (44 loc) · 931 Bytes
/
4468_카드놓기.cpp
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
#include <cstdio>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;
vector<int> resultVector;
unordered_set<string> resultSet;
bool visited[10] = {
false,
};
int n, k;
void permutation(vector<int> input, int end) {
if (resultVector.size() == end) {
string result = "";
for (int i = 0; i < resultVector.size(); i++) {
result += to_string(resultVector[i]);
}
resultSet.insert(result);
return;
}
for (int i = 0; i < n; i++) {
if (visited[i]) {
continue;
}
visited[i] = true;
resultVector.push_back(input[i]);
permutation(input, end);
visited[i] = false;
resultVector.pop_back();
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
vector<int> input(n);
for (int i = 0; i < n; i++) {
cin >> input[i];
}
permutation(input, k);
cout << resultSet.size();
return 0;
}