#include <cstdio> #include "krazki.h" #include "message.h" #include <vector> #include <algorithm> using namespace std; typedef long long ll; int n, m, single_n; int a, b; int nodes_num, my_node; vector<ll> r; int main() { n = PipeHeight(); m = NumberOfDiscs(); nodes_num = NumberOfNodes(); my_node = MyNodeId(); if(my_node == 0) { for(int i = 1 ; i <= n ; i++) HoleDiameter(i); printf("2"); } /* n = PipeHeight(); m = NumberOfDiscs(); nodes_num = NumberOfNodes(); my_node = MyNodeId(); if(n % nodes_num) single_n = n / nodes_num + 1; else single_n = n / nodes_num; a = my_node * single_n + 1; if(a > n) return 0; b = min(a + single_n - 1, n); for(int i = a ; i <= b ; i++) r.push_back(HoleDiameter(i)); if(my_node == 0) { for(int i = 1 ; i < r.size() ; i++) r[i] = min(r[i], r[i - 1]); } else { Receive(my_node - 1); ll previous = GetLL(my_node - 1); r[0] = min(previous, r[0]); for(int i = 1 ; i < r.size() ; i++) r[i] = min(r[i], r[i - 1]); } if(my_node < nodes_num - 1 && b < n) { PutLL(my_node + 1, r[r.size() - 1]); Send(my_node + 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include <cstdio> #include "krazki.h" #include "message.h" #include <vector> #include <algorithm> using namespace std; typedef long long ll; int n, m, single_n; int a, b; int nodes_num, my_node; vector<ll> r; int main() { n = PipeHeight(); m = NumberOfDiscs(); nodes_num = NumberOfNodes(); my_node = MyNodeId(); if(my_node == 0) { for(int i = 1 ; i <= n ; i++) HoleDiameter(i); printf("2"); } /* n = PipeHeight(); m = NumberOfDiscs(); nodes_num = NumberOfNodes(); my_node = MyNodeId(); if(n % nodes_num) single_n = n / nodes_num + 1; else single_n = n / nodes_num; a = my_node * single_n + 1; if(a > n) return 0; b = min(a + single_n - 1, n); for(int i = a ; i <= b ; i++) r.push_back(HoleDiameter(i)); if(my_node == 0) { for(int i = 1 ; i < r.size() ; i++) r[i] = min(r[i], r[i - 1]); } else { Receive(my_node - 1); ll previous = GetLL(my_node - 1); r[0] = min(previous, r[0]); for(int i = 1 ; i < r.size() ; i++) r[i] = min(r[i], r[i - 1]); } if(my_node < nodes_num - 1 && b < n) { PutLL(my_node + 1, r[r.size() - 1]); Send(my_node + 1); } */ return 0; } |