Submission #2164134


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dp[100005][10];

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  string y="yahoo";

  rep(i,n+1)rep(j,5)dp[i][j]=INF;

  dp[0][0]=0;

  rep(i,n)rep(j,50){

    //insert
    dp[i][(j+1)%5]=min(dp[i][(j+1)%5],dp[i][j%5]+1);

    //erase
    dp[i+1][j%5]=min(dp[i+1][j%5],dp[i][j%5]+1);
 
    //change
    if(s[i]==y[j%5]) dp[i+1][(j+1)%5]=min(dp[i+1][(j+1)%5],dp[i][j%5]);
    else  dp[i+1][(j+1)%5]=min(dp[i+1][(j+1)%5],dp[i][j%5]+1);

  }
  cout<<dp[n][0]<<endl;
}

Submission Info

Submission Time
Task A - YahooYahooYahoo
User rika0384
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1188 Byte
Status
Exec Time 41 ms
Memory 4480 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt, sample4.txt
All 400 / 400 in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
in1.txt 2 ms 256 KB
in10.txt 41 ms 4352 KB
in11.txt 41 ms 4352 KB
in12.txt 41 ms 4352 KB
in13.txt 41 ms 4480 KB
in14.txt 41 ms 4352 KB
in15.txt 40 ms 4352 KB
in16.txt 41 ms 4352 KB
in17.txt 41 ms 4352 KB
in18.txt 41 ms 4352 KB
in19.txt 41 ms 4352 KB
in2.txt 41 ms 4352 KB
in20.txt 41 ms 4352 KB
in21.txt 41 ms 4352 KB
in22.txt 40 ms 4352 KB
in23.txt 40 ms 4352 KB
in24.txt 1 ms 256 KB
in25.txt 2 ms 256 KB
in26.txt 21 ms 2304 KB
in27.txt 1 ms 256 KB
in28.txt 1 ms 256 KB
in29.txt 1 ms 256 KB
in3.txt 41 ms 4352 KB
in4.txt 41 ms 4352 KB
in5.txt 41 ms 4352 KB
in6.txt 41 ms 4352 KB
in7.txt 2 ms 256 KB
in8.txt 41 ms 4352 KB
in9.txt 41 ms 4352 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB
sample3.txt 1 ms 256 KB
sample4.txt 1 ms 256 KB