diff --git "a/ksinji/202512/18 BOJ A\354\231\200 B.md" "b/ksinji/202512/18 BOJ A\354\231\200 B.md" new file mode 100644 index 00000000..a52ee632 --- /dev/null +++ "b/ksinji/202512/18 BOJ A\354\231\200 B.md" @@ -0,0 +1,39 @@ +```java +import java.io.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String s = br.readLine(); + String t = br.readLine(); + + char[] a = t.toCharArray(); + int l = 0; + int r = a.length - 1; + boolean dir = false; + + while (r - l + 1 > s.length()) { + char last = dir ? a[l] : a[r]; + if (last == 'A') { + if (dir) l++; + else r--; + } else { + if (dir) l++; + else r--; + dir = !dir; + } + } + + for (int i = 0; i < s.length(); i++) { + char c = dir ? a[r - i] : a[l + i]; + if (c != s.charAt(i)) { + System.out.print(0); + return; + } + } + + System.out.print(1); + } +} +``` \ No newline at end of file