Advertisement
Saleh127

Live ar 6979

Jan 23rd, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. string a;
  14. ll i,j,k,l,dig,sign,need,nd,ns=0;
  15.  
  16. cin>>a;
  17. for(i=0; i<a.size(); i++)
  18. {
  19. if(a[i]=='*')
  20. {
  21. ns++;
  22. }
  23. }
  24. if(ns==0)
  25. {
  26. cout<<0<<endl;
  27. continue;
  28. }
  29. nd=a.size()-ns;
  30.  
  31. if(nd>=(ns+1))
  32. {
  33. need=0;
  34. }
  35. else need=ns+1-nd;
  36.  
  37. ll ans=need;
  38.  
  39. sign=dig=0;
  40.  
  41. for(i=0; i<a.size(); i++)
  42. {
  43. if(a[i]!='*')
  44. {
  45. dig++;
  46. }
  47. else
  48. {
  49. sign++;
  50. if(dig<(sign+1))
  51. {
  52. if(need>0)
  53. {
  54. need--;
  55. dig++;
  56. }
  57. else
  58. {
  59. ans++;
  60. sign--;
  61. dig++;
  62. }
  63. }
  64. }
  65. }
  66.  
  67. cout<<ans<<endl;
  68.  
  69. }
  70.  
  71.  
  72. return 0;
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement