Submission #1440345


Source Code Expand

#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
const string dre1="dream",dre2="dreamer";
const string ear1="erase",ear2="eraser";
const int maxn=100005;
string s;
int w[maxn],n;
void fal()
{
    cout<<"NO"<<endl;
}
bool buil()
{
    for(int i=0;i<n;i++)
    {
        if(s[i]=='d')
        {
            if(s.substr(i,7)==dre2)
            {
                if(s[i+7]=='a')
                    w[i]=i+5;
                else
                {
                    if(s[i+7]=='e')
                        w[i]=i+7;
                    else
                    {
                        cout<<"NO";
                        return 0;
                    }
                }
            }
            else
            {
                if(s.substr(i,5)==dre1)
                    w[i]=i+5;
                else
                {
                    cout<<"NO";
                    return 0;
                }
            }
        }
        else
        {
            w[i]=i+1;
        }
    }
    return 1;
}
bool ears(int x)
{
    if(s.substr(x,6)==ear2)
    {
        if(s[x+6]=='a')
            w[x]=x+5;
        else
        {
            if(s[x+6]=='e' || s[x+6]=='d')
                w[x]=x+6;
            else
            {
                fal();
                return 0;
            }
        }
    }
    else
    {
        if(s.substr(x,5)==ear1)
            w[x]=x+5;
        else
        {
            fal();
            return 0;
        }
    }
    return 1;
}
int main()
{
    cin>>s;
    n=int(s.size());
    if(!buil())
        return 0;
    for(int i=0;i<n;i=w[i])
    {
        if(w[i]!=i+1)
            continue;
        if(s[i]=='d')
        {
            fal();
            return 0;
        }
        if(!ears(i))
        {
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - Daydream
User NightRaven
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3092 Byte
Status WA
Exec Time 4 ms
Memory 512 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
WA × 1
AC × 10
WA × 9
Set Name Test Cases
Sample subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
All subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt AC 1 ms 256 KB
subtask0_1.txt WA 1 ms 256 KB
subtask0_2.txt AC 1 ms 256 KB
subtask1_0.txt AC 4 ms 512 KB
subtask1_1.txt AC 4 ms 512 KB
subtask1_10.txt WA 4 ms 512 KB
subtask1_11.txt WA 4 ms 512 KB
subtask1_12.txt WA 4 ms 512 KB
subtask1_13.txt WA 4 ms 512 KB
subtask1_14.txt AC 4 ms 512 KB
subtask1_15.txt AC 4 ms 512 KB
subtask1_2.txt AC 4 ms 512 KB
subtask1_3.txt WA 4 ms 512 KB
subtask1_4.txt AC 4 ms 512 KB
subtask1_5.txt WA 4 ms 512 KB
subtask1_6.txt AC 4 ms 512 KB
subtask1_7.txt AC 4 ms 512 KB
subtask1_8.txt WA 4 ms 512 KB
subtask1_9.txt WA 4 ms 512 KB