Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#include<cctype>

 

typedef long long int ll;

typedef vector<ll> vll;

typedef vector<vector<ll>> vvll;

typedef vector<pair<ll, ll>> vpll;

typedef map<ll, ll> mll;

typedef map<char, ll> mcl;

typedef unordered_map<ll, ll> umll;

typedef unordered_map<char, ll> umcl;

typedef set<ll> sll;

typedef pair<ll, ll> pll;

typedef queue<ll> qll;

typedef deque<ll> dqll;

typedef priority_queue<ll> pqll;

 

#define Jay ios_base::sync_with_stdio(false);

#define Shree cin.tie(NULL);

#define Ram cout.tie(NULL);

#define yes cout << "YES" << "\n";

#define no cout << "NO" << "\n";

#define nope cout<<-1<<"\n";

#define ZZ cout<<0<<"\n";

#define cspace cout<<"\n";

#define endl '\n'

#define inarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];

#define outarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;

#define all(v) v.begin(),v.end()

#define rall(v) v.rbegin(),v.rend()

#define sz(v) (ll)(v.size())

#define fl(i, n) for(ll i=0; i<n; i++)

#define f(i, x, n) for(ll i=x; i<n; i++)

#define rf(i, n) for(ll i=n-1; i>=0; i--)

#define fr(e, x) for(auto &e:x)

#define RR return;

#define fi first

#define se second

#define pb push_back

#define eb emplace_back

#define pf push_front

 

const ll MOD=1e9+7;

const ll N=1e7+7;

const ll PI=3.141592653589793238462643;

 

bool isPrime(ll n){if(n<=1) return false; if(n<=3) return true; if(n%2==0 || n%3==0) return false; for(ll i=5; i*i<=n; i+=6) {if(n%i==0 || n%(i+2)==0) return false;} return true;}

bool isPowerOfTwo(ll n){if(n==0)return false;return (ceil(log2(n))==floor(log2(n)));}

bool isPerfectSquare(ll x){if(x>=0){ll sr=sqrt(x);return (sr*sr==x);}}

bool isInteger(double n){return floor(n)==n;}

 

ll findMEX(const set<ll>&s){ll mex=0;while(s.find(mex)!=s.end()){mex++;}return mex;}

 

void solve()

{

    ll n;

    cin>>n;

    string s;

    cin>>s;

    ll p=count(all(s), 'p'), ss=count(all(s), 's'), d = count(all(s), '.');

    if(p+d==n || ss+d==n) yes

    else if((s[0]=='s'||s[0]=='.') && (s[n-1]=='p'||s[n-1]=='.') && (s[0]!='.' || s[n-1]!='.')) yes

    else no

}

 

int main()

{

    Jay Shree Ram



    int t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;

#include<cctype>

 

typedef long long int ll;

typedef vector<ll> vll;

typedef vector<vector<ll>> vvll;

typedef vector<pair<ll, ll>> vpll;

typedef map<ll, ll> mll;

typedef map<char, ll> mcl;

typedef unordered_map<ll, ll> umll;

typedef unordered_map<char, ll> umcl;

typedef set<ll> sll;

typedef pair<ll, ll> pll;

typedef queue<ll> qll;

typedef deque<ll> dqll;

typedef priority_queue<ll> pqll;

 

#define Jay ios_base::sync_with_stdio(false);

#define Shree cin.tie(NULL);

#define Ram cout.tie(NULL);

#define yes cout << "YES" << "\n";

#define no cout << "NO" << "\n";

#define nope cout<<-1<<"\n";

#define ZZ cout<<0<<"\n";

#define cspace cout<<"\n";

#define endl '\n'

#define inarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];

#define outarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;

#define all(v) v.begin(),v.end()

#define rall(v) v.rbegin(),v.rend()

#define sz(v) (ll)(v.size())

#define fl(i, n) for(ll i=0; i<n; i++)

#define f(i, x, n) for(ll i=x; i<n; i++)

#define rf(i, n) for(ll i=n-1; i>=0; i--)

#define fr(e, x) for(auto &e:x)

#define RR return;

#define fi first

#define se second

#define pb push_back

#define eb emplace_back

#define pf push_front

 

const ll MOD=1e9+7;

const ll N=1e7+7;

const ll PI=3.141592653589793238462643;

 

bool isPrime(ll n){if(n<=1) return false; if(n<=3) return true; if(n%2==0 || n%3==0) return false; for(ll i=5; i*i<=n; i+=6) {if(n%i==0 || n%(i+2)==0) return false;} return true;}

bool isPowerOfTwo(ll n){if(n==0)return false;return (ceil(log2(n))==floor(log2(n)));}

bool isPerfectSquare(ll x){if(x>=0){ll sr=sqrt(x);return (sr*sr==x);}}

bool isInteger(double n){return floor(n)==n;}

 

ll findMEX(const set<ll>&s){ll mex=0;while(s.find(mex)!=s.end()){mex++;}return mex;}

 

void solve()

{

    ll n;

    cin>>n;

    string s;

    cin>>s;

    if(s[0]=='s') s[0]='.';

    if(s[n-1]=='p') s[n-1]='.';

    if(count(all(s), 'p') && count(all(s), 's')) no

    else yes

}

 

int main()

{

    Jay Shree Ram



    int t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

}