Codeforces Round #138 (Div. 2)D. Two Strings
来源:互联网 发布:锅炉热力计算软件 编辑:程序博客网 时间:2024/06/04 19:26
猛的一看 觉得是dp 然后乱搞了一通 试了几种法子 要么wa了 要么tle了 后来看了别人的代码,豁然开朗。
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#include<vector>#include<sstream>#include<string>#include<climits>#include<stack>#include<set>#include<bitset>#include<cmath>#include<deque>#include<map>#include<queue>#define iinf 0x7f7f7f7f#define linf 1000000000000000000LL#define dinf 1e200#define eps 1e-11#define all(v) (v).begin(),(v).end()#define sz(x) x.size()#define pb push_back#define mp make_pair#define lng long long#define sqr(a) ((a)*(a))#define pii pair<int,int>#define pll pair<lng,lng>#define pss pair<string,string>#define pdd pair<double,double>#define X first#define Y second#define pi 3.14159265359#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)#define cc(i,j) memset(i,j,sizeof(i))#define two(x) ((lng)1<<(x))#define lson l , mid , rt << 1#define rson mid + 1 , r , rt << 1 | 1#define mod 1073741824#define pmod(x,y) (x%y+y)%yusing namespace std;typedef vector<int> vi;typedef vector<string> vs;template<class T> inline void checkmax(T &x,T y){ if(x<y) x=y;}template<class T> inline void checkmin(T &x,T y){ if(x>y) x=y;}template<class T> inline T Min(T x,T y){ return (x>y?y:x);}template<class T> inline T Max(T x,T y){ return (x<y?y:x);}template<class T> T Abs(T a){ return a>0?a:(-a);}template<class T> inline T lowbit(T n){ return (n^(n-1))&n;}template<class T> inline int countbit(T n){ return (n==0)?0:(1+countbit(n&(n-1)));}char s[222222],t[222222];int pos[26];int len1[222222],len2[222222];int main(){ while(scanf("%s%s",s+1,t+1)==2) { int n=strlen(t+1); int ns=strlen(s+1); cc(pos,-1); for(int i=1,j=1;i<=ns;++i) {if(s[i]==t[j]) { pos[t[j]-'a']=j++; } len1[i]=pos[s[i]-'a']; } cc(pos,-1); for(int i=ns,j=n;i>=1;--i) {if(s[i]==t[j]) { pos[t[j]-'a']=j--; } len2[i]=pos[s[i]-'a']; } bool f=1; ff(i,1,ns) if(len1[i]==-1||len2[i]==-1||len1[i]<len2[i]) { f=0;break; } puts(f?"Yes":"No"); } return 0;}
- Codeforces Round #138 (Div. 2)D. Two Strings
- Codeforces Round #138 (Div. 1), problem: (B) Two Strings
- Codeforces Round #179 (Div. 2) B. Yaroslav and Two Strings
- Codeforces Round #313 (Div. 2) D. Equivalent Strings 字符串处理
- Codeforces Round #313 (Div. 2)D. Equivalent Strings(字符串)
- Codeforces Round #313 (Div. 2) D Equivalent Strings
- Codeforces Round #313 (Div. 2) Problem D - Equivalent Strings
- Equivalent Strings(Codeforces Round #313 (Div. 2) D)
- Codeforces Round #313 (Div. 2) 560D Equivalent Strings(dos)
- Codeforces Round #358 (Div. 2) D. Alyona and Strings
- Codeforces Round #358 (Div. 2)D. Alyona and Strings
- Codeforces Round #358 (Div. 2) D. Alyona and Strings
- Codeforces Round #358 (Div. 2) D. Alyona and Strings
- Codeforces Round #358 (Div. 2) D. Alyona and Strings
- Codeforces Round #313 (Div. 2)560D. Equivalent Strings
- Codeforces Round #313 (Div. 2) D Equivalent Strings(dfs)
- Codeforces Round #358 (Div. 2) D. Alyona and Strings dp
- Codeforces Round #358 (Div. 2) D. Alyona and Strings dp
- Delphi 注册(关联)指定的扩展名
- Proactor和Reactor设计模式
- 配置与使用闪回之闪回数据归档
- 配置与使用闪回之闪回数据库
- 贪心算法之最小生成树prim与单源最短路径dijkstra
- Codeforces Round #138 (Div. 2)D. Two Strings
- 编写一个函数,要求输入年月日时分秒,输出下一个时间
- java多线程之模拟死锁
- wince 5.0,eVC 4.0通过应用程序启动控制面板的小程序
- 数据库的数据类型
- Project Euler problem 24
- 配置与使用闪回之闪回事务
- S3C2440上 MMC/SD卡驱动实例开发讲解 .
- Shell内建命令之getopts