-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscoveringPermutations.cpp
More file actions
66 lines (59 loc) · 1.21 KB
/
DiscoveringPermutations.cpp
File metadata and controls
66 lines (59 loc) · 1.21 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int MAX = 200007;
int result[MAX];
int main(){
optimize();
int t;
cin>>t;
for (int i = 1; i <=t; i++)
{
int n,k;
string s="A";
cin>>n>>k;
for (int i =1; i <n; i++)
{
s+='A'+i;
}
int cnt=0;
cout << "Case " << i << ":" << '\n';
do
{
cout<<s<<endl;
cnt++;
if(cnt==k) break;;
} while (next_permutation(s.begin(),s.end()));
}
return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;
int main()
{
int test_case;
cin >> test_case;
string all = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int t = 1; t <= test_case; t++)
{
int N, K;
cin >> N >> K;
string x, check;
x = all.substr(0, N);
check = x;
cout << "Case " << t << ":" << '\n';
for (int i = 1; i <= K; i++)
{
cout << x << '\n';
next_permutation(x.begin(), x.end());
if (x == check) break;
}
}
return 0;
}
*/
/*
Author : SALAH
"HARD WORK CAN CHANGE LUCK"
*/