Submission #782825


Source Code Expand

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

bool dp[5001][5001];

int main()
{
    string s,t;
    cin >>s >>t;

    if(s.size()>t.size()) printf("No\n");
    else if(s.size()==t.size())
    {
        if(s==t) printf("Yes\n");
        else printf("No\n");
    }
    else
    {
        if(s[0]!=t[0]) printf("No\n");
        else
        {
            fill(dp[0],dp[5001],false);
            dp[0][0]=true;

            int S=s.size(), T=t.size();

            rep(i,S)rep(j,T)
            {
                if(dp[i][j])
                {
                    //printf("%d,%d\n", i,j);

                    //s[i]とt[j]が同じ文字なので両方挿入
                    if(i+1<=S && j+1<=T)
                    {
                        //ここから先やる意味がない
                        if(dp[i+1][j+1]) continue;

                        if(s[i]==t[j])
                        {
                            dp[i+1][j+1]=true;
                            if(j+2<=T && t[j]!=t[j+1])
                            {
                                for(int k=j+2; k<=T; ++k) dp[i+1][k]=true;
                            }
                        }
                    }
                }
            }

            //rep(i,S+1)rep(j,T+1) printf("dp[%d][%d]= %d\n", i,j,(int)dp[i][j]);

            string ans="No";
            if(dp[S][T]) ans="Yes";
            cout << ans << endl;
        }
    }

    return 0;
}

Submission Info

Submission Time
Task C - 文字列の書き換え
User imulan
Language C++11 (GCC 4.8.1)
Score 5
Code Size 1770 Byte
Status AC
Exec Time 108 ms
Memory 25308 KB

Judge Result

Set Name All
Score / Max Score 5 / 5
Status
AC × 90
Set Name Test Cases
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, 061.txt, 062.txt, 063.txt, 064.txt, 065.txt, 066.txt, 067.txt, 068.txt, 069.txt, 070.txt, 071.txt, 072.txt, 073.txt, 074.txt, 075.txt, 076.txt, 077.txt, 078.txt, 079.txt, 080.txt, 081.txt, 082.txt, 083.txt, 084.txt, 085.txt, 086.txt, 087.txt, 088.txt, 089.txt
Case Name Status Exec Time Memory
000.txt AC 81 ms 25192 KB
001.txt AC 80 ms 25188 KB
002.txt AC 79 ms 25188 KB
003.txt AC 79 ms 25196 KB
004.txt AC 27 ms 792 KB
005.txt AC 79 ms 25196 KB
006.txt AC 80 ms 25192 KB
007.txt AC 77 ms 25196 KB
008.txt AC 77 ms 25188 KB
009.txt AC 80 ms 25188 KB
010.txt AC 27 ms 760 KB
011.txt AC 93 ms 25192 KB
012.txt AC 85 ms 25292 KB
013.txt AC 28 ms 864 KB
014.txt AC 92 ms 25196 KB
015.txt AC 92 ms 25204 KB
016.txt AC 92 ms 25188 KB
017.txt AC 92 ms 25184 KB
018.txt AC 85 ms 25288 KB
019.txt AC 93 ms 25192 KB
020.txt AC 108 ms 25192 KB
021.txt AC 107 ms 25288 KB
022.txt AC 25 ms 880 KB
023.txt AC 108 ms 25196 KB
024.txt AC 96 ms 25192 KB
025.txt AC 26 ms 860 KB
026.txt AC 106 ms 25196 KB
027.txt AC 107 ms 25308 KB
028.txt AC 26 ms 920 KB
029.txt AC 86 ms 25204 KB
030.txt AC 87 ms 25192 KB
031.txt AC 26 ms 924 KB
032.txt AC 84 ms 25196 KB
033.txt AC 84 ms 25308 KB
034.txt AC 28 ms 872 KB
035.txt AC 84 ms 25192 KB
036.txt AC 88 ms 25192 KB
037.txt AC 26 ms 912 KB
038.txt AC 90 ms 25196 KB
039.txt AC 91 ms 25200 KB
040.txt AC 26 ms 916 KB
041.txt AC 91 ms 25196 KB
042.txt AC 92 ms 25188 KB
043.txt AC 25 ms 868 KB
044.txt AC 93 ms 25188 KB
045.txt AC 91 ms 25196 KB
046.txt AC 27 ms 872 KB
047.txt AC 96 ms 25192 KB
048.txt AC 94 ms 25192 KB
049.txt AC 25 ms 876 KB
050.txt AC 95 ms 25188 KB
051.txt AC 96 ms 25204 KB
052.txt AC 28 ms 868 KB
053.txt AC 94 ms 25184 KB
054.txt AC 95 ms 25196 KB
055.txt AC 26 ms 916 KB
056.txt AC 27 ms 788 KB
057.txt AC 25 ms 872 KB
058.txt AC 78 ms 25196 KB
059.txt AC 26 ms 916 KB
060.txt AC 80 ms 25192 KB
061.txt AC 80 ms 25188 KB
062.txt AC 78 ms 25192 KB
063.txt AC 80 ms 25192 KB
064.txt AC 80 ms 25196 KB
065.txt AC 80 ms 25196 KB
066.txt AC 80 ms 25192 KB
067.txt AC 78 ms 25188 KB
068.txt AC 80 ms 25184 KB
069.txt AC 79 ms 25184 KB
070.txt AC 78 ms 25184 KB
071.txt AC 78 ms 25284 KB
072.txt AC 78 ms 25192 KB
073.txt AC 78 ms 25188 KB
074.txt AC 78 ms 25196 KB
075.txt AC 78 ms 25192 KB
076.txt AC 78 ms 25192 KB
077.txt AC 77 ms 25192 KB
078.txt AC 78 ms 25200 KB
079.txt AC 78 ms 25172 KB
080.txt AC 76 ms 25192 KB
081.txt AC 78 ms 25196 KB
082.txt AC 78 ms 25196 KB
083.txt AC 78 ms 25184 KB
084.txt AC 78 ms 25196 KB
085.txt AC 76 ms 25188 KB
086.txt AC 80 ms 25288 KB
087.txt AC 80 ms 25188 KB
088.txt AC 77 ms 25288 KB
089.txt AC 80 ms 25192 KB