-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB1343.java
More file actions
53 lines (41 loc) · 980 Bytes
/
B1343.java
File metadata and controls
53 lines (41 loc) · 980 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package Practice;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class B1343 { //Æú¸®¿À¹Ì³ë
public static StringBuilder sb = new StringBuilder();
public static String str;
public static int count;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
str = br.readLine();
count = 0;
for(int i = 0; i < str.length(); i++) {
if(str.charAt(i) == 'X') count++;
else if(str.charAt(i) == '.') {
if(!solve()) return;
sb.append('.');
}
}
if(count > 0) {
if(!solve()) return;
}
System.out.println(sb);
}
public static boolean solve() {
if(count % 2 != 0) {
System.out.println(-1);
return false;
}
while(count >= 4) {
count -= 4;
sb.append("AAAA");
}
if(count == 2) {
count -= 2;
sb.append("BB");
}
return true;
}
}