/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 4ms 7.297 MiB
#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) 4ms 7.824 MiB
#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) 5ms 7.82 MiB

Code

/*
ALLAH IS THE GREATEST
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl "\n"
const ll mod = 998244353;
const ll N = 2e5+7;
#define Subhanallah_Alhamdulillah_Allahu_Akbar ios_base::sync_with_stdio(false);cin.tie(NULL);
bool bs[100000007];
const ll sz = 1e6+5;
typedef pair<ll,ll>pi;
vector<ll>prime;
vector<bool>isPrime(N+1, true);
ll vis[N];
ll arr[N];
vector<ll>graph[N];
void sieve()
{
    bs[0]=bs[1]=1;
    for(ll i=3;i*i<=sz;i+=2)
    {
        if(!bs[i])
        {
            for(ll j=i*i;j<=sz;j+=i)
            {
                bs[j]=1;
            }
        }
    }
    prime.push_back(2);
    for(ll i=3;i<=sz;i+=2)
   
    {
        if(!bs[i])
        {
            //prime.push_back(i);
        }
    }
    //sort(prime.rbegin(),prime.rend());
}
void isprime()
{
    isPrime[0] = false, isPrime[1] = false;
    for(ll i = 2; i*i<=N; i++)
    {
        if(isPrime[i])
        {
            for(ll j = 2*i;j<=N; j+=i)
            {
                isPrime[j] = false;
            }
        }
    }
}
// ll mod(ll a, ll m){
//     return (a % m + m) % m;
// }
ll biexpo(ll base,ll power,ll mod)
{
    ll ans =1;
    while(power)
    {
        if(power%2==1)
        {
            ans=(ans*base)%mod;
            power--;
        }
        else
        {
            base=(base*base)%mod;
            power/=2;
        }
    }
    return ans%mod;
}
ll dfs(ll n,ll d)
{
    vector<ll>v;
    vis[n]=1;
    stack<ll>st;
    st.push(n);
    while(!st.empty())
    {
    ll cur = st.top();
    v.push_back(cur);
    st.pop();
    for(auto &i:graph[cur])
    {
        if(!vis[i])
        {
            st.push(i);
            vis[i]=1;
        }
    }
    }
    map<ll,ll>mp;
    for(ll i=0;i<v.size();i++)
    {
        mp[v[i]]++;
    }
    if(mp[d])
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
ll digsum(ll n)
{
    ll sum=0;
    while(n)
    {
        sum+=(n%10);
        n/=10;
    }
    return sum;
}
void LPS(string pat, vector<ll>&lps)
{
    ll M=pat.length();
    ll len=0;
    lps[0]=0; 
    ll i=1;
    while (i<M) 
    {
        if (pat[i]==pat[len]) 
        {
            len++;
            lps[i]=len;
            i++;
        } 
        else 
        {
            if (len!=0) 
            {
                len=lps[len-1];
            } 
            else 
            {
                lps[i]=0;
                i++;
            }
        }
    }
}
int main() {
    Subhanallah_Alhamdulillah_Allahu_Akbar
    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])
            {
                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:40:00
Judged At
2024-12-13 09:40:00
Judged By
Score
10
Total Time
5ms
Peak Memory
7.824 MiB