Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
        #include<bits/stdc++.h>

        using namespace std;

        #define ll long long

        #define test cout<<"ok"<<endl; 

        #define check(n) for(auto x:n)cout<<x<<" "

        //  p.push_back(make_pair(a,b));

        // pr.push_back({1,3});

        //factor and divisor are same which is limited & multiple are unlimited

        #define debug(x) cout << #x <<" " << x << endl;

        #define Faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

        #define MX  1000000+7

        vector < bool > is_prime(MX+ 1, true);

        /*is_prime[0] = false;

        is_prime[1] = true;

        for(int i = 2; i<= MX; i++){

            if(is_prime[i] == true && i * i <= MX)

                {

                    for(int j = i * i ; j <= MX ;j+= i)

                    {       

                        is_prime[j] = false;

                    }

                }



        }*/



        void solve(){

        ll n; cin >> n;    

         string s;

         cin >> s;

         int ppos = 0, spos = 0;

         

         for(int i = 0; i < n; i++){

           if(s[i] == 's')

            spos = i;

         }  

        

         for(int i = 0; i < n; i++){

           if(s[i] == 'p'){

            ppos = i;

            break;

           }

         } 

         

        if(ppos < spos)

            cout <<"NO" << endl;

        else {

            

            bool flag1 = false;

            bool flag2 = false;

            

            for(int i = spos-1; i >=0; i--){

                if(s[i] == '.')

                    flag1 = true;

            }

            

            for(int i = ppos+1; i <n; i++){

                if(s[i] =='.')

                    flag2 = true;

            }

            

            if(flag1 & flag2)

                    cout << "NO" << endl;

            else 

                cout << "YES" << endl;

        }

        }



        int main(){

        Faster;

        int t;   cin >> t;



        while(t --){    

            solve();

            }

        }

Submission (verdict: Wrong answer on test 2):
        #include<bits/stdc++.h>

        using namespace std;

        #define ll long long

        #define test cout<<"ok"<<endl; 

        #define check(n) for(auto x:n)cout<<x<<" "

        //  p.push_back(make_pair(a,b));

        // pr.push_back({1,3});

        //factor and divisor are same which is limited & multiple are unlimited

        #define debug(x) cout << #x <<" " << x << endl;

        #define Faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

        #define MX  1000000+7

        vector < bool > is_prime(MX+ 1, true);

        /*is_prime[0] = false;

        is_prime[1] = true;

        for(int i = 2; i<= MX; i++){

            if(is_prime[i] == true && i * i <= MX)

                {

                    for(int j = i * i ; j <= MX ;j+= i)

                    {       

                        is_prime[j] = false;

                    }

                }



        }*/



        void solve(){

        ll n; cin >> n;    

         string s;

         cin >> s;

         int ppos = -1, spos = -1;

         

         for(int i = 0; i < n; i++){

           if(s[i] == 's')

            spos = i;

         }  

        

         for(int i = 0; i < n; i++){

           if(s[i] == 'p'){

            ppos = i;

            break;

           }

         } 

         

        if(ppos == -1)

            {

                cout << "YES" << endl;

                return;

            } 

        if(ppos < spos)

            cout <<"NO" << endl;

        else {

            

            bool flag1 = false;

            bool flag2 = false;

            

            for(int i = spos-1; i >=0; i--){

                if(s[i] == '.')

                    flag1 = true;

            }

            

            for(int i = ppos+1; i <n; i++){

                if(s[i] =='.')

                    flag2 = true;

            }

            

            if(flag1 & flag2)

                    cout << "NO" << endl;

            else 

                cout << "YES" << endl;

        }

        }



        int main(){

        Faster;

        int t;   cin >> t;



        while(t --){    

            solve();

            }

        }