ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1102. Strange Dialog

Что не так? Говорит, что ошибка доступа, я не понимаю.
Posted by DarkSun1997 29 Apr 2017 03:35
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int main()
{
#ifdef _DEBUG
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#endif
    int n;
    cin>>n;
    vector<int> B(n,0);
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        vector<int> A(s.size());
        for(int j=0;j<s.size();j++)
        {
            A[j]=0;
        }
        for(int j=0;j<s.size()-2;j++)
        {
            if(A[j]==0 && A[j+1]==0 && A[j+2]==0)
                if(s[j]=='o' && s[j+1]=='n' && s[j+2]=='e')
                {
                    A[j]=1;
                    A[j+1]=1;
                    A[j+2]=1;
                }
        }
        for(int j=0;j<s.size()-4;j++)
        {
            if(A[j]==0 && A[j+1]==0 && A[j+2]==0 && A[j+3]==0 && A[j+4]==0)
                if(s[j]=='p' && s[j+1]=='u' && s[j+2]=='t' && s[j+3]=='o' && s[j+4]=='n')
                {
                    A[j]=1;
                    A[j+1]=1;
                    A[j+2]=1;
                    A[j+3]=1;
                    A[j+4]=1;
                }
        }
        for(int j=0;j<s.size()-4;j++)
        {
            if(A[j]==0 && A[j+1]==0 && A[j+2]==0 && A[j+3]==0 && A[j+4]==0)
                if(s[j]=='i' && s[j+1]=='n' && s[j+2]=='p' && s[j+3]=='u' && s[j+4]=='t')
                {
                    A[j]=1;
                    A[j+1]=1;
                    A[j+2]=1;
                    A[j+3]=1;
                    A[j+4]=1;
                }
        }
        for(int j=0;j<s.size()-5;j++)
        {
            if(A[j]==0 && A[j+1]==0 && A[j+2]==0 && A[j+3]==0 && A[j+4]==0 && A[j+5]==0)
                if(s[j]=='o' && s[j+1]=='u' && s[j+2]=='t' && s[j+3]=='p' && s[j+4]=='u'  && s[j+5]=='t')
                {
                    A[j]=1;
                    A[j+1]=1;
                    A[j+2]=1;
                    A[j+3]=1;
                    A[j+4]=1;
                    A[j+5]=1;
                }
        }
        for(int j=0;j<s.size()-1;j++)
        {
            if(A[j]==0 && A[j+1]==0)
                if(s[j]=='i' && s[j+1]=='n')
                {
                    A[j]=1;
                    A[j+1]=1;
                }
        }
        for(int j=0;j<s.size()-2;j++)
        {
            if(A[j]==0 && A[j+1]==0 && A[j+2]==0)
                if(s[j]=='o' && s[j+1]=='u' && s[j+2]=='t')
                {
                    A[j]=1;
                    A[j+1]=1;
                    A[j+2]=1;
                }
        }
        bool flag=true;
        for(int j=0;j<s.size();j++)
        {
            if(A[j]==0)
                B[i]=1;
        }

    }
    for(int i=0;i<n;i++){
    if(B[i]==0)
            cout<<"YES";
        else
            cout<<"NO";
        cout<<"\n";
    }
    return 0;
}

Edited by author 29.04.2017 03:35

Edited by author 29.04.2017 03:41