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

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

/* clang-format off */

/* TYPES  */
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define mii map<int, int>
#define si set<int>
#define sc set<char>

/* FUNCTIONS */
#define f(a,n) for(long long int i=a;i<n;i++)
#define cf(i,s,e) for(long long int i=s;i<e;i++)
#define rf(e,s) for(long long int i=e-1;i>=s;i--)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()


/* PRINTS */
template <class T>
void print_v(vector<T> &v) { cout << "{"; for (auto x : v) cout << x << ","; cout << "\b}"; }

/* UTILS */
#define M 1000000007
#define PI 3.1415926535897932384626433832795
#define read(type) readInt<type>()

ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }

string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }

string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }

bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }

#define yy cout<<"Yes\n"
#define nn cout<<"No\n"

/* -question intuitions:
- dp --compute next result from the previous result of the sequence
        -- you have a choice at each step and each choice can lead to answer

- binary search -- can sort the array or sort the answer--- find minimum or maximum from the answer sample space ->binary search on answer n(long(n))
or upper/lower bound of something in a sorted sample namespac
 --- where anwer space is sorted and in fixed range

-heap -- find lowest or largest of a segment -- k is given example kth largest or smallest
if k+smallest -- kth smallest--maxheap
if k+largest --kth largest--  minheap
complexity-- nlog(k)
*/


#define inputv(arr,n) {for(int i=0;i<n;i++)cin>>arr[i];}
#define printv(a) {for(auto u:a) cout<<u<<" "; cout<<endl;}
void solve(){
    ll n;
    cin>>n;
    
    string s;
    cin>>s;


    if(n==1){
        yy;
        return;
    }


    
    int i=0;int j = 0 ;
    while(i<n){
        if(i=='.'){
            i++;
            continue;
        }

        if(i==n-1){
            yy;
            return;
        }

        j=i+1;
        while(j<n && s[j]=='.') j++;
        if(j==n) {
            yy;
            return;
        }

        if(s[i]==s[j]){
            i=j;continue;
        }

        if(i==0 || i==n-2){
            if(s[i]!='s'){
                nn;
                return;
            }

        }else{
            nn;
            return;
        }
        i++;
    }
    yy;


}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t; cin>>t;
    while(t--){

    solve();
       




    }
    return 0;
}

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

/* clang-format off */

/* TYPES  */
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define mii map<int, int>
#define si set<int>
#define sc set<char>

/* FUNCTIONS */
#define f(a,n) for(long long int i=a;i<n;i++)
#define cf(i,s,e) for(long long int i=s;i<e;i++)
#define rf(e,s) for(long long int i=e-1;i>=s;i--)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()


/* PRINTS */
template <class T>
void print_v(vector<T> &v) { cout << "{"; for (auto x : v) cout << x << ","; cout << "\b}"; }

/* UTILS */
#define M 1000000007
#define PI 3.1415926535897932384626433832795
#define read(type) readInt<type>()

ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }

string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }

string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }

bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }

#define yy cout<<"Yes\n"
#define nn cout<<"No\n"

/* -question intuitions:
- dp --compute next result from the previous result of the sequence
        -- you have a choice at each step and each choice can lead to answer

- binary search -- can sort the array or sort the answer--- find minimum or maximum from the answer sample space ->binary search on answer n(long(n))
or upper/lower bound of something in a sorted sample namespac
 --- where anwer space is sorted and in fixed range

-heap -- find lowest or largest of a segment -- k is given example kth largest or smallest
if k+smallest -- kth smallest--maxheap
if k+largest --kth largest--  minheap
complexity-- nlog(k)
*/


#define inputv(arr,n) {for(int i=0;i<n;i++)cin>>arr[i];}
#define printv(a) {for(auto u:a) cout<<u<<" "; cout<<endl;}
void solve(){
    ll n;
    cin>>n;
    
    string s;
    cin>>s;


    string temp = "";
    for(auto it: s)
        if(it=='.')continue;
        else temp+=it;
    if(n==1 || temp == "") {
        yy;
        return;
    }
    for(int i = 1; i<n;i++){
        string curr = "";
        curr+=s[i-1];
        curr+=s[i];

        if(i==1 || i==n-1) {
            if(curr=="ps"){
                nn;
                return;
            }
        }

        else if(curr=="sp" || curr=="ps"){
            nn;
            return;
        }
    }
    yy;




}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t; cin>>t;
    while(t--){

    solve();
       




    }
    return 0;
}