#include "cstdio" #include "cstdlib" #include "algorithm" #include "vector" #include "krazki.h" #include "message.h" using namespace std; long long n, m, ile, x, k; vector <long long> tab2, tab3; bool ok; int main() { n = PipeHeight(); m = NumberOfDiscs(); if (MyNodeId() == 1) { tab3.push_back (HoleDiameter(1)); for (int i=1; i<n; i++) tab3.push_back(min(HoleDiameter(i+1),tab3[i-1])); x=n; for (int i=0; i<m; i++) { k=x-1; while (k>0) { if (tab3[k]>=DiscDiameter(i+1)) break; k--; } x=k; if (x<=0) break; } if (x>0) x++; PutLL(0, x); Send(0); } else if (MyNodeId() == 0) { Receive(1); printf ("%lld\n", GetLL(1)); } 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 38 39 40 41 42 43 44 45 46 | #include "cstdio" #include "cstdlib" #include "algorithm" #include "vector" #include "krazki.h" #include "message.h" using namespace std; long long n, m, ile, x, k; vector <long long> tab2, tab3; bool ok; int main() { n = PipeHeight(); m = NumberOfDiscs(); if (MyNodeId() == 1) { tab3.push_back (HoleDiameter(1)); for (int i=1; i<n; i++) tab3.push_back(min(HoleDiameter(i+1),tab3[i-1])); x=n; for (int i=0; i<m; i++) { k=x-1; while (k>0) { if (tab3[k]>=DiscDiameter(i+1)) break; k--; } x=k; if (x<=0) break; } if (x>0) x++; PutLL(0, x); Send(0); } else if (MyNodeId() == 0) { Receive(1); printf ("%lld\n", GetLL(1)); } return 0; } |