// kompromitacja ;_; #include "poszukiwania.h" #include "message.h" #include <cstdio> #include <algorithm> using namespace std; typedef long long int lld; int main() { lld n = SeqLength(); lld m = SignalLength(); int i = MyNodeId(); int N = NumberOfNodes(); lld mn = max(n/lld(N),1LL); lld pocz = lld(i)*mn; lld kon = lld(i+1)*mn; if(i == N-1) kon = n-m+1; kon=min(kon,n-m+1); lld wyn = 0; for(lld k = pocz;k<kon;k++) { bool ok=true; for(lld j=0;j<m;j++) { if(SeqAt(k+j+1LL)!=SignalAt(j+1LL)) { ok=false; break; } } if(ok)wyn++; } if(i==0) { for(int j=1;j<N;j++) { Receive(j); wyn+=GetLL(j); } printf("%lld\n",wyn); } else { PutLL(0,wyn); Send(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 38 39 40 41 42 43 44 45 46 47 48 49 50 | // kompromitacja ;_; #include "poszukiwania.h" #include "message.h" #include <cstdio> #include <algorithm> using namespace std; typedef long long int lld; int main() { lld n = SeqLength(); lld m = SignalLength(); int i = MyNodeId(); int N = NumberOfNodes(); lld mn = max(n/lld(N),1LL); lld pocz = lld(i)*mn; lld kon = lld(i+1)*mn; if(i == N-1) kon = n-m+1; kon=min(kon,n-m+1); lld wyn = 0; for(lld k = pocz;k<kon;k++) { bool ok=true; for(lld j=0;j<m;j++) { if(SeqAt(k+j+1LL)!=SignalAt(j+1LL)) { ok=false; break; } } if(ok)wyn++; } if(i==0) { for(int j=1;j<N;j++) { Receive(j); wyn+=GetLL(j); } printf("%lld\n",wyn); } else { PutLL(0,wyn); Send(0); } } |