#include <iostream> #include "futbol.h" #include "message.h" using namespace std; typedef unsigned long long ull; const int COORDINATOR_ID = 0; const int NODES_COUNT = 100; inline void gather_results(long long result) { ull accumulated_result = result; for (int i = 1; i < NODES_COUNT; ++i) { Receive(i); accumulated_result += GetLL(i); } cout << accumulated_result << endl; } inline void sent_result(long long result) { PutLL(COORDINATOR_ID, result); Send(COORDINATOR_ID); } inline void solve() { int instance_number = MyNodeId(); long long result = (instance_number == 99 ? 11 : 0); if (instance_number == COORDINATOR_ID) { gather_results(result); } else { sent_result(result); } } int main() { ios_base::sync_with_stdio(0); solve(); 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 <iostream> #include "futbol.h" #include "message.h" using namespace std; typedef unsigned long long ull; const int COORDINATOR_ID = 0; const int NODES_COUNT = 100; inline void gather_results(long long result) { ull accumulated_result = result; for (int i = 1; i < NODES_COUNT; ++i) { Receive(i); accumulated_result += GetLL(i); } cout << accumulated_result << endl; } inline void sent_result(long long result) { PutLL(COORDINATOR_ID, result); Send(COORDINATOR_ID); } inline void solve() { int instance_number = MyNodeId(); long long result = (instance_number == 99 ? 11 : 0); if (instance_number == COORDINATOR_ID) { gather_results(result); } else { sent_result(result); } } int main() { ios_base::sync_with_stdio(0); solve(); return 0; } |