Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

#define ll long long

#define ull unsigned long long

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)

#define pqueue priority_queue

using namespace std;

ll get(ll n, ll i) { return (n&(1ll<<i)) ? 1 : 0; }

ll on(ll n, ll i) { return (n|(1ll<<i)); }

ll off(ll n, ll i) { return (n&(~(1ll<<i))); }

ll flip(ll n, ll i) { return (n^(1ll<<i)); }

void setIO(string name = "") {

    if (name.size()) {

        freopen((name + ".in").c_str(), "r", stdin);

        freopen((name + ".out").c_str(), "w", stdout);

    }

}

int main ()

{

    fast;

    //setIO("guess");

    int t; cin>>t;

    while (t--)

    {

        int n, pos = 0; cin>>n;

        string s, ans = "YES\n"; cin>>s;

        map<pair<int, int>, int> mp;

        map<char, int> mp2;

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

        {

            ++mp2[s[i]];

            if (s[i] == 'p' and i!=n-1)

            {

                ++mp[{1, i+1}];

                if (mp[{1, i+1}] == 2)

                    ans = "NO\n";

            }

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

            {

                ++mp[{1, n-i}];

                if (mp[{1, n-i}] == 2)

                    ans = "NO\n";

            }

        }

        if (mp2['s']>1 and mp2['p']>1)

            ans = "NO\n";

        if (mp2['s'] and mp2['p'])

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

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

                    pos = 1;

                else if (pos)

                    ans = "NO\n";

        cout<<ans;

    }

}

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

#define ll long long

#define ull unsigned long long

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)

#define pqueue priority_queue

using namespace std;

ll get(ll n, ll i) { return (n&(1ll<<i)) ? 1 : 0; }

ll on(ll n, ll i) { return (n|(1ll<<i)); }

ll off(ll n, ll i) { return (n&(~(1ll<<i))); }

ll flip(ll n, ll i) { return (n^(1ll<<i)); }

void setIO(string name = "") {

    if (name.size()) {

        freopen((name + ".in").c_str(), "r", stdin);

        freopen((name + ".out").c_str(), "w", stdout);

    }

}

int main ()

{

    fast;

    //setIO("guess");

    int t; cin>>t;

    while (t--)

    {

        int n, pos = 0; cin>>n;

        string s, ans = "YES\n"; cin>>s;

        map<pair<int, int>, int> mp;

        map<char, int> mp2;

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

        {

            ++mp2[s[i]];

            if (s[i] == 'p' and i!=n-1)

            {

                ++mp[{1, i+1}];

                if (mp[{1, i+1}] == 2)

                    ans = "NO\n";

            }

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

            {

                ++mp[{1, n-i}];

                if (mp[{1, n-i}] == 2)

                    ans = "NO\n";

            }

        }

        if (mp2['s']>1 and mp2['p']>1)

            ans = "NO\n";

        if (mp2['s'] and mp2['p'])

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

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

                    pos = 1;

                else if (s[i] == 's' and pos)

                    ans = "NO\n";

        cout<<ans;

    }

}