-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccc.cpp
More file actions
65 lines (63 loc) · 872 Bytes
/
ccc.cpp
File metadata and controls
65 lines (63 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char w[2502],m[2502];
scanf("%s%s",m,w);
int count=0;
if(strlen(m)<=strlen(w))
{
int j=strlen(m)+1;
m[strlen(m)]='$';
m[strlen(m)+1]='\0';
strcat(m,w);
for(int i=0;i<strlen(m);i++)
{
if(m[i]==m[j])
{
j++;
count++;
}
else if(m[i]=='$')
break;
else{
i--;
j++;
}
}
if(count==strlen(m))
printf("YES\n");
else
printf("NO\n");
}
else{
int j=strlen(w)+1;
w[strlen(w)]='$';
w[strlen(w)+1]='\0';
strcat(w,m);
for(int i=0;i<strlen(w);i++)
{
if(w[i]==w[j])
{
j++;
count++;
}
else if(w[i]=='$')
break;
else{
i--;
j++;
}
}
if(count==strlen(w))
printf("YES\n");
else
printf("NO\n");
}
}
return 0;
}