-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1023.cpp
More file actions
39 lines (38 loc) · 774 Bytes
/
1023.cpp
File metadata and controls
39 lines (38 loc) · 774 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
#include <bits/stdc++.h>
using namespace std;
vector<char> v;
char arr[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
int n, k = 0, ct = 0;
int visit[30] = {0};
void check(void) {
if (ct == k) return;
if (v.size() == n) {
for (int i = 0; i < n; i++) {
printf("%c", v[i]);
}
printf("\n");
ct++;
return;
}
for (int i = 0; i < n; i++) {
if (visit[i] == 0) {
visit[i] = 1;
v.push_back(arr[i]);
check();
v.pop_back();
visit[i] = 0;
}
}
}
int main() {
int i = 0, t;
scanf("%d", &t);
while (t--) {
i++;
ct = 0;
scanf("%d %d", &n, &k);
printf("Case %d:\n", i);
check();
}
return 0;
}