fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define el cout << '\n'
  5.  
  6. using namespace std;
  7.  
  8. int t, n, x;
  9. string s;
  10.  
  11. int main()
  12. {
  13. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  14. if (fopen("B.INP", "r"))
  15. {
  16. freopen("B.INP", "r", stdin);
  17. freopen("B.OUT", "w", stdout);
  18. }
  19.  
  20. cin >> t;
  21. while (t--)
  22. {
  23. cin >> n >> x;
  24. cin >> s;
  25. s = ' ' + s;
  26. int fi = 0;
  27. int lt = n + 1;
  28. for (int i = 1; i <= n; i++)
  29. {
  30. if (s[i] == '.')
  31. continue;
  32. if (i < x)
  33. fi = max(fi, i);
  34. else if (i > x)
  35. lt = min(lt, i);
  36. }
  37. cout << max(min(x - 1, n - lt + 1), min(fi, n - x)) + 1, el;
  38. }
  39. }
  40.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty