-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10567.cpp
More file actions
executable file
·58 lines (55 loc) · 1.14 KB
/
10567.cpp
File metadata and controls
executable file
·58 lines (55 loc) · 1.14 KB
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
#include <bits/stdc++.h>
using namespace std;
char arr[1000009];
int binary_search(int l,int r,char val)
{
int mid=l+(r-l)/2;
if(r>=l)
{
if(l==r)return mid;
else if(arr[mid]<val)return binary_search(mid+1,r,val);
else return binary_search(l,mid,val);
}
else return -1;
}
int main()
{
int aa,bb;
int i=0;
char c;
while(true)
{
cin>>c;
if(c=='\n')break;
arr[i]=c;
i++;
}
int tsize=i;
int n;
cin>>n;
string s;
bool check=true;
while(n--)
{
cin>>s;
int start=0;
for(int i=0; i<s.size(); i++)
{
int temp;
temp=binary_search(start,tsize-1,s[i]);
if(arr[temp]!=s[i])
{
check =false;
break;
}
else
{
if(i==0)aa=temp;
else if(i==s.size())bb=temp;
start=++temp;
}
}
if(check)cout<<"Matched "<<aa<<" "<<bb<<endl;
else cout<<"Not matched"<<endl;
}
}