Codeforces Round 911 (Div. 2) 1900A. Cover in Water Solution



Problem Link : https://codeforces.com/contest/1900/problem/A 

Solution in C++:

  1. /// Author : AH_Tonmoy
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int32_t main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n ;
  11. cin >> n ;
  12. string s ;
  13. cin >> s ;
  14. bool ok = false ;
  15. int cnt = 0 , cnt1 = 0;
  16. for (int i = 0 ; i < n ; i++){
  17. cnt1 = 0 ;
  18. while(s[i] =='.'){
  19. cnt1++ , cnt++,i++;
  20. if (cnt1 >= 3){
  21. ok = true ;
  22. break ;
  23. }
  24. }
  25. }
  26. if (ok){
  27. cout <<"2\n";
  28. }
  29. else{
  30. cout << cnt <<endl;
  31. }
  32. }
  33. return 0 ;
  34. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.