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
#include "poszukiwania.h"
#include "message.h"
#include <algorithm>
#include <iostream>
using namespace std;
bool ok;
long long S,M,res;
int main() 
{
	ios_base::sync_with_stdio(0);
	S = SignalLength();
	M = SeqLength();
	res = 0;
	for (int i=MyNodeId(); i<=M-S; i+=NumberOfNodes())
	{
		ok=true;
		for (int j=1; j<=S; j++)
		{
			if(SignalAt(j) != SeqAt(j+i))
			{
				ok=false;
				break;
			}
		}
		if (ok) res++;
	}
	if (MyNodeId() > 0)
	{
		PutInt(0, res);
		Send(0);
	}
	else
	{
		for (int i=1; i < NumberOfNodes(); ++i)
		{
			Receive(i);
			res += GetInt(i);
		}
		cout<<res<<"\n";
  }
}