#include "poszukiwania.h"
#include "message.h"
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
long long M = SeqLength();
long long S = SignalLength();// s<=m
long long wyn = 0, temp;
for(long long i = 0; i <= M - S ; i = i + NumberOfNodes())
{
temp = 0;
long long j;
for (j = i + MyNodeId() +1; j <= min(i + MyNodeId() + S + 1 , M) ; j++) {
if( SignalAt( j - MyNodeId()-i ) != SeqAt(j)) break;
else temp++;
}
if( temp == S ) wyn++;
}
if (MyNodeId() > 0) {
PutLL(0, wyn);
Send(0);
}
else {
for (int instancja = 1; instancja < NumberOfNodes(); ++instancja) {
Receive(instancja);
wyn += GetLL(instancja);
}
cout << wyn << endl;
}
return 0;
}
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 | #include "poszukiwania.h" #include "message.h" #include <algorithm> #include <iostream> using namespace std; int main() { long long M = SeqLength(); long long S = SignalLength();// s<=m long long wyn = 0, temp; for(long long i = 0; i <= M - S ; i = i + NumberOfNodes()) { temp = 0; long long j; for (j = i + MyNodeId() +1; j <= min(i + MyNodeId() + S + 1 , M) ; j++) { if( SignalAt( j - MyNodeId()-i ) != SeqAt(j)) break; else temp++; } if( temp == S ) wyn++; } if (MyNodeId() > 0) { PutLL(0, wyn); Send(0); } else { for (int instancja = 1; instancja < NumberOfNodes(); ++instancja) { Receive(instancja); wyn += GetLL(instancja); } cout << wyn << endl; } return 0; } |
English