-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva10567.cpp
More file actions
55 lines (51 loc) · 1.12 KB
/
uva10567.cpp
File metadata and controls
55 lines (51 loc) · 1.12 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
/* Rishikesh
* UVA 10567
* Helping Fill Bates
* The hint from cp3 book was very helpful
*/
#include<iostream>
#include<string>
#include<sstream>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cstdint>
#include<numeric>
#include<stack>
#include<queue>
#include<list>
#include<deque>
#include<bitset>
using namespace std;
int main() {
map<char, vector<int>> mm;
string s;
int q;
cin >> s;
for (size_t i=0; i< s.length(); i++) {
mm[s[i]].push_back(i);
}
cin >> q;
while(q--) {
cin >> s;
int found = true;
int first = *upper_bound(mm[s[0]].begin(), mm[s[0]].end(), -1);
int last = first;
for (size_t i = 1; i< s.length(); i++) {
auto it = upper_bound(mm[s[i]].begin(), mm[s[i]].end(), last);
if (it == mm[s[i]].end()) {
found = false;
break;
}
last = *it;
}
if (found) {
cout << "Matched " <<first << " " << last << endl;
} else {
cout << "Not matched\n";
}
}
}