Codeforces Round 911 (Div. 2) 1900A. Cover in Water Solution
Problem Link : https://codeforces.com/contest/1900/problem/A
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n ;
- cin >> n ;
- string s ;
- cin >> s ;
- bool ok = false ;
- int cnt = 0 , cnt1 = 0;
- for (int i = 0 ; i < n ; i++){
- cnt1 = 0 ;
- while(s[i] =='.'){
- cnt1++ , cnt++,i++;
- if (cnt1 >= 3){
- ok = true ;
- break ;
- }
- }
- }
- if (ok){
- cout <<"2\n";
- }
- else{
- cout << cnt <<endl;
- }
- }
- return 0 ;
- }
No comments