Skip to content

Commit 228e4fa

Browse files
committed
NHAY - A Needle in the Haystack
1 parent 7150313 commit 228e4fa

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

SPOJ/NHAY.cpp

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* Amit Bansal - @amitbansal7 */
2+
#include <bits/stdc++.h>
3+
#include <string>
4+
#define lli long long int
5+
#define llu unsigned long long int
6+
#define S(x) scanf("%d",&x)
7+
#define Sl(x) scanf("%lld",&x)
8+
#define Mset(p,i) memset(p,i,sizeof(p))
9+
#define mlc(t,n) (t *)malloc(sizeof(t)*n)
10+
#define NIL -1
11+
#define INF 0x3f3f3f3f
12+
#define TC int testcase; S(testcase); while(testcase--)
13+
#define Pi 3.14159
14+
using namespace std;
15+
16+
int main()
17+
{
18+
string a;
19+
string b;
20+
21+
int n;
22+
while(scanf("%d",&n)!=EOF)
23+
{
24+
cin>>a;
25+
cin>>b;
26+
int match = 0;
27+
if(a.length() > b.length())
28+
continue;
29+
30+
else
31+
{
32+
for(int j=0;j<b.length();j++)
33+
{
34+
int i = 0;
35+
if(a[i] == b[j])
36+
{
37+
int tj = j;
38+
i++;
39+
j++;
40+
41+
while(a[i] == b[j] && j < b.length())
42+
{
43+
i++;
44+
j++;
45+
}
46+
47+
if(n == i)
48+
{
49+
match = 1;
50+
printf("%d\n",tj);
51+
}
52+
53+
j = tj;
54+
}
55+
}
56+
}
57+
if(match == 0)
58+
printf("\n");
59+
60+
printf("\n");
61+
}
62+
return 0;
63+
}
64+

0 commit comments

Comments
 (0)