B. Dima and Text Messages
思路很简单,字符串匹配,顺序扫一遍,o(n)的算法,居然TLE~~~~
原因居然是strlen
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define For(a,b) for(int a=0;a<b;a++)
#define mem(x) memset(x,0,sizeof(x))
#define Debug(x) cout<<"---> "<<x<<endl;
#define sf scanf
#define pf printf
int gcd(int a,int b){ return b>0?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int ,int > P;
//head
#define maxn 300100
string s,ss,ps;
int m,n,k;
int main(){cin>>n;ss="<3";for(int i=0;i<n;i++){cin>>s;ss+=s;ss+="<3";}m=ss.size();cin>>ps;int len=ps.length();//ss是输入的字符串,ps是匹配的字符串 for(int i=0;i<len;i++){if(ss[k]==ps[i]){k++;}if(k>=m){ //匹配结束 cout<<"yes"<<endl;return 0; }}cout<<"no"<<endl;return 0;
}