-
Notifications
You must be signed in to change notification settings - Fork 2
/
e.java
51 lines (48 loc) · 1.23 KB
/
e.java
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
import java.util.*;
public class e {
static boolean comp(String a, String b, char x, char y) {
if((x == a.charAt(0) && y == a.charAt(1)) || (x == b.charAt(0) && y == b.charAt(1))) {
return true;
}
return false;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
String s = in.next(), t = in.next();
String perm[] = {"abc", "acb", "bac", "bca", "cab", "cba"};
System.out.println("YES");
if(s.charAt(0) == s.charAt(1) || t.charAt(0) == t.charAt(1)) {
String good = null;
for(String i : perm) {
if(comp(s, t, i.charAt(0), i.charAt(1)) || comp(s, t, i.charAt(1), i.charAt(2)) || comp(s, t, i.charAt(2), i.charAt(0))) {
continue;
}
good = i;
break;
}
for(int i = 0; i < N; i++) {
for(int j = 0; j < 3; j++) {
System.out.print(good.charAt(j));
}
}
System.out.println();
}else {
String good = null;
for(String i : perm) {
if(comp(s, t, i.charAt(0), i.charAt(1)) || comp(s, t, i.charAt(1), i.charAt(2))) {
continue;
}
good = i;
break;
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < N; j++) {
System.out.print(good.charAt(i));
}
}
System.out.println();
}
in.close();
}
}