Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 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. void K4(char ch){
  7.     tC = tK4 + 4;
  8. }
  9. void K3(char ch){
  10.     if (ch == 'B'){
  11.         tB = tK3 + 2;
  12.     }
  13.     else{
  14.         tC = tK3 + 4;
  15.     }
  16. }
  17. void K2(char ch){
  18.     tB = tK2 + 2;
  19. }
  20. void K1(char ch){
  21.     if (ch == 'B'){
  22.         if (tK3 <= tK2){
  23.             tK3 = tK1 + 4;
  24.             K3(ch);
  25.         }
  26.         else{
  27.             tK2 = tK1 + 6;
  28.             K2(ch);
  29.         }
  30.     }
  31.     else{
  32.         if (tK3 <= tK4){
  33.             tK3 = tK1 + 8;
  34.             K3(ch);
  35.         }
  36.         else {
  37.             tK4 = tK1 + 12;
  38.             K4(ch);
  39.         }
  40.     }
  41. }
  42. void A(char ch){
  43.     if (ch == 'B'){
  44.         tK1 += 1;
  45.     }
  46.     else tK1 += 2;
  47.     K1(ch);
  48. }
  49. int main(){
  50.     for (int i = 0; i < 16; ++i){
  51.         char ch;
  52.         cin >> ch;
  53.         A(ch);
  54.     }
  55.     cout << max(tB, tC);
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement