File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 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+ if (dir) l++ ;
23+ else r-- ;
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+ ```
You can’t perform that action at this time.
0 commit comments