/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 492.0 KiB
#2 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::erase: __pos (which is 8) > this->size() (which is 4) 2ms 796.0 KiB
#3 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::erase: __pos (which is 16) > this->size() (which is 9) 2ms 796.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define nl "\n"
int main() {
    ll t=1;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        string s;
        cin>>s;
        string x = "SeriousOJ";
        reverse(s.begin(),s.end());
        reverse(x.begin(),x.end());
        for(ll i=0;i<n;i++)
        {
            if(x.empty())
            {
                break;
            }
            if(x[0]==s[i])
            {
                if(!x.empty())
                {
                    x.erase(i);
                } 
            }
        }
        if(x.empty())
        {
            cout<<"YES"<<nl;
        }
        else
        {
            cout<<"NO"<<nl;
        }
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1147 SeriousOJ Challenge
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-13 09:46:36
Judged At
2024-12-13 09:46:36
Judged By
Score
10
Total Time
2ms
Peak Memory
796.0 KiB