-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpingFillBates.cpp
83 lines (72 loc) · 1.62 KB
/
helpingFillBates.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
81
82
83
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("helpingFillBates.in");
ofstream fout("helpingFillBates.out");
struct store
{
int start;
int end;
};
int main()
{
string a;
fin >> a;
int size0 = a.size(),count0 = 0;
fin >> count0;
for (int c = 1; c <= count0; ++c)
{
string in;
fin >> in;
bool ok = true;
int size1 = in.size(), i1 = 0, last = 0, lastPos = -1;
for (int i0 = 0; i0 <= size1 - 1; ++i0)
{
string temp = "";
temp.push_back(in[i0]);
int result = a.find(temp, last);
if (i0 == size1 - 1)
{
if (result != string::npos)
{
lastPos = result;
}
}
if (last == 0)
{
last = result + 1;
}
else if (result == string::npos)
{
ok = false;
break;
}
else if (result < last)
{
ok = false;
break;
}
else
{
last = result + 1;
}
}
if (ok == true)
{
fout << "Matched " << a.find(in[0]) << ' ' << lastPos << '\n';
}
else
{
fout << "Not matched\n";
}
}
return 0;
}