Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. int tA = 0, tC = 0, tB = 0, tK1 = 0, tK2 = 0, tK3 = 0, tK4 = 0;
  5.  
  6. queue<int> q;
  7. void K4(char ch){
  8.     tC = tK4 + 4;
  9. }
  10. void K3(char ch){
  11.     if (ch == 'B'){
  12.         tB = tK3 + 2;
  13.     }
  14.     else{
  15.         tC = tK3 + 4;
  16.     }
  17. }
  18. void K2(char ch){
  19.     tB = tK2 + 2;
  20. }
  21. void K1(char ch){
  22.     if (ch == 'B'){
  23.         q.push(6);
  24.     }
  25.     else{
  26.         q.push(12);
  27.     }
  28.     int tmp = q.front();
  29.     if (tK3 <= tK1){
  30.         if (tmp == 6){
  31.             tK3 = tK1 + 4;
  32.             K3('B');
  33.         }
  34.         else{
  35.             tK3 = tK1 + 8;
  36.             K3('C');
  37.         }
  38.         q.pop();
  39.     }
  40.     else if (tmp == 6 && tK2 <= tK1){
  41.         tK2 = tK1 + 6;
  42.         K2('B');
  43.         q.pop();
  44.     }
  45.     else if (tmp == 12 && tK4 <= tK1){
  46.         tK4 = tK1 + 12;
  47.         K4('C');
  48.         q.pop();
  49.     }
  50. }
  51. void A(char ch){
  52.     if (ch == 'B'){
  53.         tK1 += 1;
  54.     }
  55.     else tK1 += 2;
  56.     K1(ch);
  57. }
  58. int main(){
  59.     for (int i = 0; i < 16; ++i){
  60.         char ch;
  61.         cin >> ch;
  62.         A(ch);
  63.     }
  64.     cout << max(tB, tC);
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement