Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- typedef long long ll;
- using namespace std;
- int tA = 0, tC = 0, tB = 0, tK1 = 0, tK2 = 0, tK3 = 0, tK4 = 0;
- queue<int> q;
- void K4(char ch){
- tC = tK4 + 4;
- }
- void K3(char ch){
- if (ch == 'B'){
- tB = tK3 + 2;
- }
- else{
- tC = tK3 + 4;
- }
- }
- void K2(char ch){
- tB = tK2 + 2;
- }
- void K1(char ch){
- if (ch == 'B'){
- q.push(6);
- }
- else{
- q.push(12);
- }
- int tmp = q.front();
- if (tK3 <= tK1){
- if (tmp == 6){
- tK3 = tK1 + 4;
- K3('B');
- }
- else{
- tK3 = tK1 + 8;
- K3('C');
- }
- q.pop();
- }
- else if (tmp == 6 && tK2 <= tK1){
- tK2 = tK1 + 6;
- K2('B');
- q.pop();
- }
- else if (tmp == 12 && tK4 <= tK1){
- tK4 = tK1 + 12;
- K4('C');
- q.pop();
- }
- }
- void A(char ch){
- if (ch == 'B'){
- tK1 += 1;
- }
- else tK1 += 2;
- K1(ch);
- }
- int main(){
- for (int i = 0; i < 16; ++i){
- char ch;
- cin >> ch;
- A(ch);
- }
- cout << max(tB, tC);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement