Submission #2550054


Source Code Expand

import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int q = sc.nextInt();
		
		int[] sMod = new int[s.length()+1];
		sMod[0] = 0;
		for (int i=1;i<=s.length();i++) {
			sMod[i] = (sMod[i-1] + (s.charAt(i-1)=='A' ? 1 : 2))%3;
		}
		int[] tMod = new int[t.length()+1];
		tMod[0] = 0;
		for (int i=1;i<=t.length();i++) {
			tMod[i] = (tMod[i-1] + (t.charAt(i-1)=='A' ? 1 : 2))%3;
		}
		
		for (int i=0;i<q;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			int x = (sMod[b] - sMod[a-1] + 3) % 3;
			int y = (tMod[d] - tMod[c-1] + 3) % 3;
			
			System.out.println(x==y ? "YES" : "NO");
		}
	}

}

Submission Info

Submission Time
Task E - TrBBnsformBBtion
User shinike
Language Java7 (OpenJDK 1.7.0)
Score 600
Code Size 846 Byte
Status AC
Exec Time 1339 ms
Memory 97664 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 16
Set Name Test Cases
Sample 0_000.txt, 0_001.txt
All 0_000.txt, 0_001.txt, bound_0.txt, bound_1.txt, bound_2.txt, bound_3.txt, min.txt, rnd_10000_10.txt, rnd_10000_10000.txt, rnd_10000_2.txt, rnd_10_10.txt, rnd_10_10000.txt, rnd_10_2.txt, rnd_2_10.txt, rnd_2_10000.txt, rnd_2_2.txt
Case Name Status Exec Time Memory
0_000.txt AC 95 ms 16980 KB
0_001.txt AC 96 ms 18772 KB
bound_0.txt AC 1285 ms 95544 KB
bound_1.txt AC 1306 ms 94356 KB
bound_2.txt AC 1310 ms 93504 KB
bound_3.txt AC 1339 ms 94208 KB
min.txt AC 94 ms 20436 KB
rnd_10000_10.txt AC 1327 ms 91960 KB
rnd_10000_10000.txt AC 1298 ms 97280 KB
rnd_10000_2.txt AC 1305 ms 93172 KB
rnd_10_10.txt AC 1304 ms 93052 KB
rnd_10_10000.txt AC 1307 ms 93028 KB
rnd_10_2.txt AC 1306 ms 95852 KB
rnd_2_10.txt AC 1289 ms 96008 KB
rnd_2_10000.txt AC 1314 ms 94388 KB
rnd_2_2.txt AC 1302 ms 97664 KB