-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSA01019-HAHAHA.cpp
52 lines (46 loc) · 1.18 KB
/
DSA01019-HAHAHA.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
//https://github.com/tminoshy
//created by Đỗ Thiện Minh at 16/09/2024
#include <iostream>
#include <vector>
using namespace std;
void generateHAHA(int index, int sz, vector<char>& sequence) {
if (index == sz) {
for (const char &c : sequence) {
cout << c;
}
cout << endl;
return;
}
if(index == 0) {
sequence[index] = 'H';
generateHAHA(index + 1, sz, sequence);
} else if (index == sz - 1) {
sequence[index] = 'A';
generateHAHA(index + 1, sz, sequence);
} else {
if (sequence[index - 1] != 'H') {
sequence[index] = 'A';
generateHAHA(index + 1, sz, sequence);
sequence[index] = 'H';
generateHAHA(index + 1, sz, sequence);
} else {
sequence[index] = 'A';
generateHAHA(index + 1, sz, sequence);
}
}
}
void Testcase() {
int N; cin >> N;
vector<char> sequence(N);
generateHAHA(0, N, sequence);
}
int main() {
int testCount;
cin >> testCount;
while(testCount--) {
Testcase();
}
return 0;
}
//B23DCCE064
//HAHAHA