-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshift_and.cpp
More file actions
49 lines (36 loc) · 872 Bytes
/
shift_and.cpp
File metadata and controls
49 lines (36 loc) · 872 Bytes
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
#include<bits/stdc++.h>
#include<omp.h>
using namespace std;
int main() {
ifstream fin;
string a, t;
fin.open("1.txt");
getline(fin, t);
fin.close();
cin>>a;
int n = t.size(), m = a.size();
int **D = new int*[m];
for(long long i=0;i<m;i++) {
D[i] = new int[n];
}
vector<int> index;
double start = omp_get_wtime();
for(int i=0;i<m;i++) D[i][0] = 0;
for(int i=0;i<n;i++) D[0][i] = (t[i] == a[0]) ? 1 : 0;
for(int i=1;i<m;i++) {
for(int l=1;l<n;l++) {
D[i][l] = (a[i] == t[l] && D[i-1][l-1]) ? 1 : 0;
}
}
double end = omp_get_wtime();
for(int l=0;l<n;l++) {
if(D[m-1][l])
index.push_back(l);
}
for(auto it : index) {
cout<<it<<" ";
}
cout<<"\n";
cout<<"Time: "<<end-start<<"\n";
return 0;
}