Submission #1838946
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 100005; int q; int fs[N], ft[N]; string s, t; int main() { ios_base::sync_with_stdio(false); cin.tie(0); string s, t; cin >> s >> t; int ns = s.size(); int nt = t.size(); // numA - numB for (int i = 1; i <= ns; ++i) fs[i] = fs[i-1] + (s[i-1] == 'A' ? +1 : -1); for (int i = 1; i <= nt; ++i) ft[i] = ft[i-1] + (t[i-1] == 'A' ? +1 : -1); // can swap two positions: AB -> AAA -> ABBA -> BBBBA -> BA // relevant: modulo 3 cin >> q; while(q--) { int a, b, c, d; cin >> a >> b >> c >> d; int S = fs[b] - fs[a - 1]; int T = ft[d] - ft[c - 1]; int dif = (T - S); if (dif % 3 == 0) printf("YES\n"); else printf("NO\n"); } }
Submission Info
Submission Time | |
---|---|
Task | E - TrBBnsformBBtion |
User | cheater2k |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 735 Byte |
Status | AC |
Exec Time | 40 ms |
Memory | 1744 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
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 | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
bound_0.txt | AC | 34 ms | 1744 KB |
bound_1.txt | AC | 36 ms | 1744 KB |
bound_2.txt | AC | 36 ms | 1744 KB |
bound_3.txt | AC | 40 ms | 1744 KB |
min.txt | AC | 1 ms | 256 KB |
rnd_10000_10.txt | AC | 38 ms | 1744 KB |
rnd_10000_10000.txt | AC | 38 ms | 1744 KB |
rnd_10000_2.txt | AC | 38 ms | 1744 KB |
rnd_10_10.txt | AC | 38 ms | 1744 KB |
rnd_10_10000.txt | AC | 38 ms | 1744 KB |
rnd_10_2.txt | AC | 38 ms | 1744 KB |
rnd_2_10.txt | AC | 38 ms | 1744 KB |
rnd_2_10000.txt | AC | 38 ms | 1744 KB |
rnd_2_2.txt | AC | 38 ms | 1744 KB |