-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTwo_Small_Strings.cpp
More file actions
54 lines (41 loc) · 1.16 KB
/
Two_Small_Strings.cpp
File metadata and controls
54 lines (41 loc) · 1.16 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
// https://codeforces.com/contest/1213/problem/E
// idea : https://github.com/Just-A-Visitor/Coding/blob/master/Codeforces%20Contests/CF%20Round%20582/Images/ReadMe.md
#define DEBUG
#define MAXN 1e9+10
#include <bits/stdc++.h>
using namespace std;
int main ()
{
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef DEBUG
freopen("in.in", "r", stdin);
#endif
int n;
cin >> n;
string a, b;
cin >> a >> b;
string sub = "abc";
string ans;
bool flag = false;
do {
string test;
for (int i = 0; i < n; ++i) test+=sub;
if (test.find(a) == string::npos && test.find(b) == string::npos) {
flag = true;
ans = test;
break;
} else {
test = string(n, sub[0])+string(n, sub[1])+string(n, sub[2]);
if (test.find(a) == string::npos && test.find(b) == string::npos) {
flag = true;
ans = test;
break;
}
}
} while (next_permutation(sub.begin(), sub.end()));
if (flag) {
cout << "YES\n";
cout << ans << endl;
} else cout << "NO\n";
return 0;
}