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

Previous submission (verdict: Wrong answer on test 1):
/*****************************
File: B_pspspsps.cpp
Time & Date:
17:25 (GMT+06:00)
Wednesday, 01-Jan-2025 

Author:
SAYFULLAH MONSUR SUJAN SARKAR
3rd year B.Sc. Engineering Student
Department of Information and Communication Engineering
University of Rajshahi, Bangladesh
******************************/

#include <bits/stdc++.h>
using namespace std;

/************ Selfmade Debugger ************/
#ifdef SAIFULLAH
    #include <ICE/debugger>
#else
    #define debug(...)   991
    #define line()     992
    #define cendl()    993
    #define cerr       if(false)cerr
#endif

time_t ms() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count();
}

/******* Policy Based Data Structure *******/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

/***************** Typedefs ****************/
typedef  long long                   ll;
typedef  pair<int, int>              pint;
typedef  pair<long long, long long>  pll;
typedef  vector<int>                 vi;
typedef  vector<long long>           vll;

/******* Defines for long statements *******/
#define  pb        push_back
#define  ff        first
#define  ss        second
#define  yes       cout << "YES\n"
#define  no        cout << "NO\n"
#define  nai       cout << "-1\n"
#define  nl        "\n"
#define  all(x)    x.begin(), x.end()
#define  allr(x)   x.rbegin(), x.rend()

/**** Disable Synchronization between C++ and C Standard Streams ****/
#define  fastIO    cout << "FastIO\n"; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

/************* Constant Values *************/
const int MOD = 1e9+7;
const ll INF = 1e18+10;

void solve(int tt) {
    cerr << "Testcase: " << tt << "\n";
    int n;
    cin >> n;
    string str;
    cin >> str;
    
    bool p_paisi = false;
    for(int i = 0; i < n; i++) {
        if(str[i] == 'p') {
            p_paisi = true;
        } else if(str[i] == 's' && p_paisi) {
            cerr << "1\n";
            no;
            return;
        }
    }

    for(int i = 1; i < n; i++) {
        if(str[i] == 's' || str[i] == '.') {
            for(int j = i+1; j < n-1; j++) {
                if(str[j] == 'p') {
                    cerr << "2\n";
                    no;
                    return;
                }
            }
        }
    }
    yes;
    return;
}

int32_t main(int32_t argc, char* argv[]) {
    #ifdef SAIFULLAH
        time_t start = ms();
    #else
        fastIO;
    #endif

    int t = 1;
    cin >> t;
    for( int i = 1 ; i <= t ; i++ )
        solve(i);

    #ifdef SAIFULLAH
        time_t end = ms();
        cerr << "\nTime: " << end - start << "ms";
    #endif

    return 0;
}

Submission (verdict: Accepted):
/*****************************
File: B_pspspsps.cpp
Time & Date:
17:25 (GMT+06:00)
Wednesday, 01-Jan-2025 

Author:
SAYFULLAH MONSUR SUJAN SARKAR
3rd year B.Sc. Engineering Student
Department of Information and Communication Engineering
University of Rajshahi, Bangladesh
******************************/

#include <bits/stdc++.h>
using namespace std;

/************ Selfmade Debugger ************/
#ifdef SAIFULLAH
    #include <ICE/debugger>
#else
    #define debug(...)   991
    #define line()     992
    #define cendl()    993
    #define cerr       if(false)cerr
#endif

time_t ms() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count();
}

/******* Policy Based Data Structure *******/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

/***************** Typedefs ****************/
typedef  long long                   ll;
typedef  pair<int, int>              pint;
typedef  pair<long long, long long>  pll;
typedef  vector<int>                 vi;
typedef  vector<long long>           vll;

/******* Defines for long statements *******/
#define  pb        push_back
#define  ff        first
#define  ss        second
#define  yes       cout << "YES\n"
#define  no        cout << "NO\n"
#define  nai       cout << "-1\n"
#define  nl        "\n"
#define  all(x)    x.begin(), x.end()
#define  allr(x)   x.rbegin(), x.rend()

/**** Disable Synchronization between C++ and C Standard Streams ****/
#define  fastIO    cerr << "FastIO\n"; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

/************* Constant Values *************/
const int MOD = 1e9+7;
const ll INF = 1e18+10;

void solve(int tt) {
    cerr << "Testcase: " << tt << "\n";
    int n;
    cin >> n;
    string str;
    cin >> str;
    
    bool p_paisi = false;
    for(int i = 0; i < n; i++) {
        if(str[i] == 'p') {
            p_paisi = true;
        } else if(str[i] == 's' && p_paisi) {
            cerr << "1\n";
            no;
            return;
        }
    }

    for(int i = 1; i < n; i++) {
        if(str[i] == 's') {
            for(int j = i+1; j < n-1; j++) {
                if(str[j] == 'p') {
                    cerr << "2\n";
                    no;
                    return;
                }
            }
        }
    }
    yes;
    return;
}

int32_t main(int32_t argc, char* argv[]) {
    #ifdef SAIFULLAH
        time_t start = ms();
    #else
        fastIO;
    #endif

    int t = 1;
    cin >> t;
    for( int i = 1 ; i <= t ; i++ )
        solve(i);

    #ifdef SAIFULLAH
        time_t end = ms();
        cerr << "\nTime: " << end - start << "ms";
    #endif

    return 0;
}