Submission #1687654
Source Code Expand
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++) const ll mod = 1e9 + 7; const int INF = 1e9; int main() { cin.sync_with_stdio(false); string S, T; cin >> S >> T; int q; cin >> q; while (q) { q--; int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--; d--; string s1,s2, t1,t2; reps(i, a, b + 1) { s1.push_back(S[i]); } reps(i, c, d + 1) { t1.push_back(T[i]); } bool flag = true; while (flag) { flag = false; rep(i,s1.size()) { int siz = s1.size(); if (i < siz-2) { int cnta = 0, cntb = 0; reps(j, i, i + 3) { if (s1[j] == 'A')cnta++; else cntb++; } if(cnta&&cntb)s2.push_back((cnta>cntb ? 'A' : 'B')); flag = true; i+=2; } else s2.push_back(s1[i]); } s1 = s2; s2 = {""}; } flag = true; while (flag) { flag = false; rep(i, t1.size()) { int siz = t1.size(); if (i < siz-2) { int cnta = 0, cntb = 0; reps(j, i, i + 3) { if (t1[j] == 'A')cnta++; else cntb++; } if(cnta&&cntb)t2.push_back((cnta>cntb ? 'A' : 'B')); flag = true; i += 2; } else t2.push_back(t1[i]); } t1 = t2; t2 = {""}; } if (s1 == "AA")s1 = 'B'; if (s1 == "BB")s1 = 'A'; if (t1 == "AA")t1 = 'B'; if (t1 == "BB")t1 = 'A'; //cout << s1 << " " << t1 << endl; if (s1 == t1)cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - TrBBnsformBBtion |
User | agis |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1621 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 1032 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | TLE | 2103 ms | 944 KB |
bound_1.txt | TLE | 2103 ms | 1032 KB |
bound_2.txt | TLE | 2103 ms | 944 KB |
bound_3.txt | TLE | 2103 ms | 944 KB |
min.txt | AC | 1 ms | 256 KB |
rnd_10000_10.txt | TLE | 2103 ms | 916 KB |
rnd_10000_10000.txt | TLE | 2103 ms | 916 KB |
rnd_10000_2.txt | TLE | 2103 ms | 912 KB |
rnd_10_10.txt | TLE | 2103 ms | 932 KB |
rnd_10_10000.txt | TLE | 2103 ms | 920 KB |
rnd_10_2.txt | TLE | 2103 ms | 912 KB |
rnd_2_10.txt | TLE | 2103 ms | 900 KB |
rnd_2_10000.txt | TLE | 2103 ms | 912 KB |
rnd_2_2.txt | TLE | 2103 ms | 868 KB |