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
#include <iostream>
#include <string>
#include <vector>
#include "poszukiwania.h"
#include "message.h"
#include <map>

#define KMPH(z) while( k > 0 && SignalAt(k) != z(q)) k = p[k]; \
if(SignalAt(k) == z(q))k++;

using namespace std;
/*
int SignalLength()
{
    return 1;
}
int SeqLength(){
    return 1;
}
int SignalAt(int a){
    return 1;
}
int SeqAt(int a){
    return 1;
}
int MyNodeId(){
    return 1;
}
*/
int main()
{
    long long wynik = 0;
    int  p[25000000] ;//[ SignalLength() +1];
    int k = 0 , q , m ;

    p[1] = 0;

    for(q =1 ; SignalLength() ; q++)
    {
        KMPH(SignalAt);
        p[q+1] = k;
    }

    m = q;
    k = 0;

    for(q = 0 ; SeqLength() ; q++)
    {
        KMPH(SeqAt);
        if(m == k)
        {
            k = p[k];
            wynik++;
        }
    }
    if(MyNodeId() == 0)cout<<wynik;

}
/*
#include <iostream>

using namespace std;

int main()
{
    for(int i=0; 0==1; i++)
    {
        cout<<"Czo ja tu robie"<<endl;
    }
}*/