Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <map>
  5. #include <algorithm>
  6. #include <cmath>
  7. #include <string>
  8.  
  9. using namespace std;
  10. typedef long long ll;
  11. typedef vector<ll> vll;
  12. typedef vector<vector<ll>> vvll;
  13.  
  14.  
  15. int main(){
  16.     int T;
  17.     cin >> T;
  18.     while (T--){
  19.         bool lose = false;
  20.         int num_killable = 0;
  21.         int weird_size = 0;
  22.  
  23.         int a, b;
  24.         cin >> a >> b;
  25.         string s;
  26.         cin >> s;
  27.         s += 'X';
  28.         int len=0;
  29.         for (char c : s){
  30.             if (c=='.') len++;
  31.             else{
  32.                 if (len>=b){
  33.                     if(len > 4*b+a-2) {lose = true;}
  34.                     else if(len >= b && len < a) lose = true;
  35.                     else if(len >= a && len < 2*b) num_killable++;
  36.                     else{
  37.                         num_killable++;
  38.                         if (weird_size != 0) lose = true;
  39.                         else weird_size = len;
  40.                     }
  41.                 }
  42.                 len = 0;
  43.             }
  44.         }
  45.         if (lose){
  46.             cout << "NO\n";
  47.             continue;
  48.         }
  49.         if (weird_size!=0){
  50.             bool even = false, odd = false;
  51.             if (weird_size <= a+2*b-2) even = true;
  52.             if (weird_size <= a + 3*b-2 && weird_size >= 2*a) odd = true;
  53.             if (weird_size >= 3*a && weird_size <=a+4*b-2) even = true;
  54.             if (even && odd){
  55.                 cout << "YES\n";
  56.                 continue;
  57.             }
  58.             if (!even && !odd) {
  59.                 cout << "NO\n";
  60.                 continue;
  61.             }
  62.             if (odd) num_killable++;
  63.         }
  64.         if (num_killable%2==0){
  65.             cout << "NO\n";
  66.         }
  67.         else{
  68.             cout << "YES\n";
  69.         }
  70.     }  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement