-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSUBS.cpp
55 lines (53 loc) · 1.05 KB
/
SUBS.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
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
bool comp(string y,string x)
{
lld n,o,p,cnt=0;
for(int i=0; i<y.size(); i++)
{
if(y[i]==x[cnt])
cnt++;
if(cnt==x.size())
break;
}
if(cnt==x.size())
return 1;
else
return 0;
}
string match(string x,lld mid)
{ string s="";
for(int i=0; i<x.size(); i++)
for(int j=0; j<mid; j++)
s+=x[i];
return s;
}
int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
string x,y;
while(t--)
{
x=y="";
cin>>x>>y;
int hp=y.size()/x.size();
int beg=0,end=hp,res=0;
while(beg<=end)
{
lld mid=(beg+end)/2;
if(comp(y,match(x,mid)))
{
if(res<mid)
res=mid;
beg=mid+1;
}
else
end=mid-1;
}
cout<<res<<"\n";
}
}