Wow! Such Doge!(KMP做法)

2023-11-23 16:00
文章标签 kmp wow 做法 doge

本文主要是介绍Wow! Such Doge!(KMP做法),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在这里插入图片描述
Chen, Adrian (November 7, 2013). “Doge Is An Ac- tually Good Internet Meme. Wow.”. Gawker. Retrieved November 22, 2013.

Doge is an Internet meme that became popular in 2013. The meme typically con- sists of a picture of a Shiba Inu dog ac- companied by multicolored text in Comic Sans MS font in the foreground. The text, representing a kind of internal monologue, is deliberately written in broken English, and usually contains the word “wow” and the phrases “such x”, “much x”, “many x”, “very x” and “so x”.
Kabosu, the Shiba Inu featured in the original meme, was first pictured in a 2010 blog post by Atsuko Sato, a Japanese kindergarten teacher. Afterwards, varia- tions of the pictures using overlaid Comic Sans text were posted from a Tumblr blog, Shiba Confessions. However, the use of the intentionally misspelled “doge” dates back to June 2005, when it was mentioned in an episode of Homestar Runners puppet series.
In August 2013, images of the meme were spammed on Reddit’s r/MURICA subreddit by 4chan’s random imageboard, /b/. A search of the term doge on Google Trends shows an explosion of popularity occurring in October 2013, and more so in the following month. By November 2013, the meme had become widespread on the Internet. Google later created a Doge Easter egg: when doge meme was entered into the YouTube search bar, all of the site’s text would be displayed in colorful Comic Sans, similar to the kind used by the meme.
The meme was ranked #12 on MTV’s list of “50 Things Pop Culture Had Us Giving Thanks For” in 2013. Io9 compared the internal dialog of the Shiba Inu dogs to lolcat-speak. The image most commonly associated with the meme is of a female Shiba Inu named Kabosu, taken from a Japanese blog documenting the dog’s daily activities. The spelling of doge has several variants, leading to debate on its actual pronunciation. On December 13, Doge was named the “top meme” of 2013 by Know Your Meme.
In December 2013, the Dogecoin was introduced as a new cryptocurrency, making it the first cryptocurrency to be based on an Internet meme; the viral phenomenon, along with usage of the Comic Sans MS typeface, gave it “the Internet density of a large star” according to Medium writer Quinn Norton.
In late December 2013, members of the U.S. Congress produced material in the meme’s style. Huffington Post commented that Doge was “killed” because of the Congress members’ usage of the meme.
By early 2014, Doge’s popularity was sustained by internet communities on social media, accompanied by the rapid growth and acceptance of Dogecoin. In April 2014, Doge experienced a second major media resurgence due to revelations of the Dogecoin community’s intent to sponsor Josh Wise in NASCAR and place a picture of the Shiba Inu on his vehicle.

—— Doge (meme). (2014, May 18).
In Wikipedia, The Free Encyclopedia. Retrieved 02:00, May 22, 2014, from
http://en.wikipedia.org/w/index.php?title=Doge_(meme)&oldid=609040691

Now, Doge wants to know how many words “doge” are there in a given article. Would you like to help Doge solve this problem?
Input
An article that Doge wants to know.
The size of the article does not exceed 64KB. The article contains only ASCII characters.
Output
Please output the number of word “doge” (case-insensitive). Refer to the samples for more details.
Sample Input
adoge
cutedo
yourge
blownDoge
lovelyDooge
Wow! Such Dooooooooooooooge!!!
D0ge
dOge DOGE
dogedoge
Sample Output
6
低端的题目往往需要用到高级的解题方法(doge)

#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int Next_doge[10];
int Next_Doge[10];
int Next_dOge[10];
int Next_doGe[10];
int Next_dogE[10];
int Next_DOge[10];
int Next_DoGe[10];
int Next_DogE[10];
int Next_dOGe[10];
int Next_dOgE[10];
int Next_doGE[10];
int Next_DOGe[10];
int Next_dOGE[10];
int Next_DOGE[10];
void getnext(int next[], const char str[])
{int m = strlen(str);int j = 0, k = -1;next[0] = -1;while (j < m){if (k == -1 || str[j] == str[k]){j++;k++;next[j] = k;}elsek = next[k];}
}
int kmp(const char str1[],const char str2[], int Next[])
{int cnt = 0;int i = 0, j = 0;int n = strlen(str1);int m = strlen(str2);while (i < n){if (j == -1 || str1[i] == str2[j]){i++;j++;}elsej = Next[j];if (j == m){cnt++;j = 0;}}return cnt;
}
void init_next()
{getnext(Next_doge, "doge");getnext(Next_Doge, "Doge");getnext(Next_dOge, "dOge");getnext(Next_doGe, "doGe");getnext(Next_dogE, "dogE");getnext(Next_DOge, "DOge");getnext(Next_DoGe, "DoGe");getnext(Next_DogE, "DogE");getnext(Next_dOGe, "dOGe");getnext(Next_dOgE, "dOgE");getnext(Next_doGE, "doGE");getnext(Next_DOGe, "DOGe");getnext(Next_dOGE, "dOGE");getnext(Next_DOGE, "DOGE");
}
int main()
{int cnt = 0;char s1[100000];init_next();while(cin >> s1)cnt += kmp(s1, "doge", Next_doge)+ kmp(s1, "Doge", Next_Doge) + kmp(s1, "dOge", Next_dOge) + kmp(s1, "doGe", Next_doGe) + kmp(s1, "dogE", Next_dogE) + kmp(s1, "DOge", Next_DOge) + kmp(s1, "DoGe", Next_DoGe) + kmp(s1, "DogE", Next_DogE) + kmp(s1, "dOGe", Next_dOGe) + kmp(s1, "DOgE", Next_dOgE) + kmp(s1, "doGE", Next_doGE) + kmp(s1, "DOGe", Next_DOGe) + kmp(s1, "dOGE", Next_dOGE) + kmp(s1, "DOGE", Next_DOGE);cout << cnt << endl;return 0;
}

233333333

这篇关于Wow! Such Doge!(KMP做法)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/419084

相关文章

codeforces535D:Tavas and Malekas(KMP)

(i-1 , i)有重合的时候 ,从第i位开始的子串必须是模式串的前缀。 而同时,从第i位开始的子串本来就已经是模式串的后缀了。 typedef long long LL ;const int maxn = 1000008 ;int next[maxn] ;void getnext(char s[]){int len = strlen(s) ;next[0] = -1 ;i

fzu 2275 Game KMP

Problem 2275 Game Time Limit: 1000 mSec    Memory Limit : 262144 KB  Problem Description Alice and Bob is playing a game. Each of them has a number. Alice’s number is A, and Bob’s number i

KMP 详解

KMP数组存的是什么 对于一个字符串 b,下标从1开始。 则kmp[i]表示 以i结尾的连续子串 = s的前缀的最大值(等价于前缀最大结尾处) 如何求KMP 假设 i 以前的KMP都被求出来了。 j 表示上一个字符可以成功匹配的长度(等价于下标) 如果b[j+1] != b[i]下一个位置匹配不上(即不能成为前缀) 则,让j = kmp[j] 即成为以j结尾的 连续子串 的 最长前缀

KMP算法详解 --- 彻头彻尾理解KMP算法

前言     之前对kmp算法虽然了解它的原理,即求出P0···Pi的最大相同前后缀长度k。   但是问题在于如何求出这个最大前后缀长度呢?   我觉得网上很多帖子都说的不是很清楚,总感觉没有把那层纸戳破,   后来翻看算法导论32章 字符串匹配,虽然讲到了对前后缀计算的正确性,但是大量的推理证明不大好理解,没有与程序结合起来讲。   今天我在这里讲一讲我的一些理解,希望大家多多指教

扩展KMP --- HDU 3613 Best Reward

Best Reward Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=3613   Mean:  给你一个字符串,每个字符都有一个权值(可能为负),你需要将这个字符串分成两个子串,使得这两个子串的价值之和最大。一个子串价值的计算方法:如果这个子串是回文串,那么价值就是这个子串所有字符权值之和;否则价值为0。

贪心问题n位数删除s位94页第3种做法

// 贪心问题n位数删除s位94页第3种做法.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。//2024-4-15#include <iostream>#include<string>using namespace std;void del(char n[],int b,int k,int& len){for (int i = b; b < len - k;i+

最长上升子序列 二分做法

给定一个长度为N的数列,求数值严格单调递增的子序列的长度最长是多少。 输入格式 第一行包含整数N。 第二行包含N个整数,表示完整序列。 输出格式 输出一个整数,表示最大长度。 数据范围 1≤N≤10001≤N≤1000, −109≤数列中的数≤109−109≤数列中的数≤109 输入样例: 73 1 2 1 8 5 6 输出样例: 4 二分做出的答案只有数量是最长上升子

P3313 [SDOI2014] 旅行(分块做法)

~~~~~      P3313 [SDOI2014] 旅行 ~~~~~      总题单链接 思路 ~~~~~      遇到这种树上路径问题,就考虑用重链剖分转为区间问题。 ~~~~~      问题转换为了:给定一个区间和 k k k,求这个区间内信仰为 k k k 的城市的 权值和 或 最大权值。 ~~~~~      这个问题也可以用动态开点线段树解决(现在不会,以后

数据结构串的实现以及KMP改进算法

</pre><pre name="code" class="cpp">#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define MAXSIZE 40 /* 存储空间初始分配量 */typedef int Status; /* Status是

字符串匹配算法之KMP算法和BM算法

[尊重原创]-原文链接在这里->http://blogread.cn/it/article/3975?f=wb 本文主要介绍KMP算法和BM算法,它们分别是前缀匹配和后缀匹配的经典算法。所谓前缀匹配是指:模式串和母串的比较从左到右,模式串的移动也是从左到右;所谓后缀匹配是指:模式串和母串的的比较从右到左,模式串的移动从左到右。看得出来前缀匹配和后缀匹配的区别就仅仅在于比较的顺序不同。下文分别