From df4cc041d263facd7b9a742ab8ca90d9813b577b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=8B=A0=EC=A7=80?= <101992179+ksinji@users.noreply.github.com> Date: Thu, 18 Dec 2025 17:04:43 +0900 Subject: [PATCH] =?UTF-8?q?[20251218]=20BOJ=20/=20G5=20/=20A=EC=99=80=20B?= =?UTF-8?q?=20/=20=EA=B0=95=EC=8B=A0=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "ksinji/202512/18 BOJ A\354\231\200 B.md" | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "ksinji/202512/18 BOJ A\354\231\200 B.md" 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