Submission #1210409


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int cntS[2][100010];
int cntT[2][100010];

signed main() {
	string S, T;
	cin >> S >> T;

	REP(i, 1, S.size()) {
		cntS[S[i - 1] - 'A'][i] = 1;
	}
	REP(i, 1, T.size()) {
		cntT[T[i - 1] - 'A'][i] = 1;
	}
	rep(j, 2) {
		REP(i, 1, S.size()) {
			cntS[j][i] += cntS[j][i - 1];
		}
		REP(i, 1, T.size()) {
			cntT[j][i] += cntT[j][i - 1];
		}
	}

	int q;
	cin >> q;
	rep(loop, q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		int sa = cntS[0][b] - cntS[0][a - 1];
		int sb = cntS[1][b] - cntS[1][a - 1];
		int ta = cntT[0][d] - cntT[0][c - 1];
		int tb = cntT[1][d] - cntT[1][c - 1];

		int sdif = sa - sb;
		int tdif = ta - tb;

		int dif = sdif - tdif;

		if (dif < 0) dif *= -1;
		cout << (dif % 3 ? "NO" : "YES") << endl;
	}

    return 0;
}

Submission Info

Submission Time
Task E - TrBBnsformBBtion
User iwashi31
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1713 Byte
Status
Exec Time 297 ms
Memory 3968 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt
All 600 / 600 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 1 ms 256 KB
0_001.txt 1 ms 256 KB
bound_0.txt 256 ms 3968 KB
bound_1.txt 269 ms 3968 KB
bound_2.txt 270 ms 3968 KB
bound_3.txt 283 ms 3968 KB
min.txt 1 ms 256 KB
rnd_10000_10.txt 281 ms 3968 KB
rnd_10000_10000.txt 282 ms 3968 KB
rnd_10000_2.txt 279 ms 3968 KB
rnd_10_10.txt 282 ms 3968 KB
rnd_10_10000.txt 279 ms 3968 KB
rnd_10_2.txt 297 ms 3968 KB
rnd_2_10.txt 280 ms 3968 KB
rnd_2_10000.txt 280 ms 3968 KB
rnd_2_2.txt 276 ms 3968 KB