Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 26339 | Accepted: 10691 |
Description
Input
Output
Sample Input
sequence subsequence person compression VERDI vivaVittorioEmanueleReDiItalia caseDoesMatter CaseDoesMatter
Sample Output
Yes No Yes NoSource Code Problem: 1936 Memory: 560K Time: 0MS Language: GCC Result: Accepted Source Code #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 100005 int SolveCase_1(char *s, char *t) { char *temp_s = s; int count_s=0 ,number, i, j; while(*temp_s != '\0') { count_s++; temp_s ++; } for(i=0, j=0, number=0; i < MAX; i++) { if(t[j]=='\0' || s[i] =='\0') break; if(t[j]==s[i]){ number++; j++; }else{ number=0; j++; } } if(number == count_s) return 1; return 0; } int SolveCase_2(char *s, char *t) { int count_t = 0; char *temp_t = t; char *temp_s = s; int count_s =0, i, j; while(*temp_t != '\0') { temp_t ++; count_t ++; } while(*temp_s != '\0') { temp_s ++; count_s ++; } for(i = 0,j = 0; i < count_t; i++) { if(s[j] == '\0' || t[i]=='\0') break; if(s[j]==t[i]) j++; if(j==count_s) break; } if(j==count_s) return 1; return 0; } int main() { // freopen("i.txt","r",stdin); char s[MAX], t[MAX]; memset(s, '\0', sizeof(s)); memset(t, '\0', sizeof(t)); while(scanf("%s%s", s, t) !=EOF) { if(SolveCase_1(s, t)!=1){ if(SolveCase_2(s, t)!=1) printf("No\n"); else printf("Yes\n"); }else printf("Yes\n"); memset(s, '\0', sizeof(s)); memset(t, '\0', sizeof(t)); } return 0; }