-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
80 lines (76 loc) · 1.56 KB
/
B.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
int main()
{
fastio;
int n,i,j,p=0;
string s,t;
cin>>s>>t;
n=s.size();
if(t.size()==1)
{
for(i=0;i<n-1;i++)
{
if(s[i]==t[0])
{
p=1;
break;
}
}
if(p==1)
cout<<"Yes\n";
else
cout<<"No\n";
}
else
{
p=-1;
int idx;
for(i=0;i<n;i++)
{
if(s[i]==t[0])
{
idx=i+1;
p=0;
break;
}
}
if(p==-1)
{
cout<<"No\n";
return 0;
}
for(i=idx;i<n;i++)
{
if(s[i-1]==t[0])
{
for(j=2*i;j<=n;j++)
{
string tmp;
if(s[j-1]==t[1])
{
tmp.push_back(s[i-1]);
tmp.push_back(s[j-1]);
for(int k=2*j-i;k<=n;k+=j-i)
{
tmp.push_back(s[k-1]);
}
}
if(tmp==t)
{
p=1;
break;
}
}
}
if(p==1)
break;
}
if(p==1)
cout<<"Yes\n";
else
cout<<"No\n";
}
return 0;
}