We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e9c5121 commit df4cc04Copy full SHA for df4cc04
1 file changed
ksinji/202512/18 BOJ A와 B.md
@@ -0,0 +1,39 @@
1
+```java
2
+import java.io.*;
3
+
4
+public class Main {
5
+ public static void main(String[] args) throws Exception {
6
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7
8
+ String s = br.readLine();
9
+ String t = br.readLine();
10
11
+ char[] a = t.toCharArray();
12
+ int l = 0;
13
+ int r = a.length - 1;
14
+ boolean dir = false;
15
16
+ while (r - l + 1 > s.length()) {
17
+ char last = dir ? a[l] : a[r];
18
+ if (last == 'A') {
19
+ if (dir) l++;
20
+ else r--;
21
+ } else {
22
23
24
+ dir = !dir;
25
+ }
26
27
28
+ for (int i = 0; i < s.length(); i++) {
29
+ char c = dir ? a[r - i] : a[l + i];
30
+ if (c != s.charAt(i)) {
31
+ System.out.print(0);
32
+ return;
33
34
35
36
+ System.out.print(1);
37
38
+}
39
+```
0 commit comments