#include "cielib.h" #include <vector> #include <iostream> using namespace std; const int MAXD=500; int main() { int v[MAXD]; int v2[MAXD]; int d = podajD(); int r = podajR(); for (int i = 0; i < d; i++) v[i] = (r+1)/2; for (int i = 0; i < d; i++) v2[i] = v[i] + 1; vector<int> b(d, 1); vector<int> e(d, r); int f = 0; while (f<d) { for (int i = 0; i < d; i++) { if (b[i] < e[i]) { int rrr = e[i] - b[i] + 1; int rr = rrr/2; v[i] = b[i]; czyCieplo(v); v[i] = e[i]; bool a1 = czyCieplo(v); bool a2 = false; if (rrr%2 == 0) { v2[i] = b[i]; czyCieplo(v2); v2[i] = e[i]; a2 = czyCieplo(v2); } if (a1||a2) { b[i] = b[i] + rr; if ((rrr%2 == 0) && a1 != a2) { e[i] = b[i]; } } else { e[i] = e[i] - rr; } v[i] = (b[i]+e[i])/2; if (b[i] >= e[i]) { f++; v2[i] = v[i]; } else v2[i] = v[i] + 1; } } } znalazlem(v); 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 70 71 72 73 | #include "cielib.h" #include <vector> #include <iostream> using namespace std; const int MAXD=500; int main() { int v[MAXD]; int v2[MAXD]; int d = podajD(); int r = podajR(); for (int i = 0; i < d; i++) v[i] = (r+1)/2; for (int i = 0; i < d; i++) v2[i] = v[i] + 1; vector<int> b(d, 1); vector<int> e(d, r); int f = 0; while (f<d) { for (int i = 0; i < d; i++) { if (b[i] < e[i]) { int rrr = e[i] - b[i] + 1; int rr = rrr/2; v[i] = b[i]; czyCieplo(v); v[i] = e[i]; bool a1 = czyCieplo(v); bool a2 = false; if (rrr%2 == 0) { v2[i] = b[i]; czyCieplo(v2); v2[i] = e[i]; a2 = czyCieplo(v2); } if (a1||a2) { b[i] = b[i] + rr; if ((rrr%2 == 0) && a1 != a2) { e[i] = b[i]; } } else { e[i] = e[i] - rr; } v[i] = (b[i]+e[i])/2; if (b[i] >= e[i]) { f++; v2[i] = v[i]; } else v2[i] = v[i] + 1; } } } znalazlem(v); return 0; } |