#include "cielib.h" #include <stdio.h> #include <stdlib.h> int lastSuccessful = -1; int* arr; bool report(int x, int nth) { //int* p = new int[podajD()]; for (int i = 0; i < podajD(); i++) { if (i == nth) arr[i] = x; else arr[i] = 0; } if (czyCieplo(arr)) { lastSuccessful = x; return true; } return false; } int bin(int nth) { int min = 0, max = podajR(); int guess = 0; int dec = max; bool r; int mid; report(0, nth); while ((max - min) > 1) { guess = min + max - guess; r = report(guess, nth); mid = (min + max) / 2; if (dec == min) { if (r) { max = mid; } else { min = mid; } dec = max; } else { if (r) { min = mid; } else { max = mid; } dec = min; } } int* a = new int[podajD()]; int op = (dec == min) ? max : min; int op2 = (dec == min) ? min : max; report(op2, nth); if (report(op, nth)) { //a[0] = op; return op; } else { //a[0] = op2; return op2; } //znalazlem(a); } int main() { int d = podajD(); int k = podajK(); int r = podajR(); int* pos = new int[d]; arr = new int[d]; for (int i = 0; i < d; i++) { pos[i] = 0; arr[d] = 0; } for (int i = 0; i < d; i++) { pos[i] = bin(i); } //for (int i = 0; i < d; i++) //{ // cout << pos[i] << " "; //} znalazlem(pos); 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #include "cielib.h" #include <stdio.h> #include <stdlib.h> int lastSuccessful = -1; int* arr; bool report(int x, int nth) { //int* p = new int[podajD()]; for (int i = 0; i < podajD(); i++) { if (i == nth) arr[i] = x; else arr[i] = 0; } if (czyCieplo(arr)) { lastSuccessful = x; return true; } return false; } int bin(int nth) { int min = 0, max = podajR(); int guess = 0; int dec = max; bool r; int mid; report(0, nth); while ((max - min) > 1) { guess = min + max - guess; r = report(guess, nth); mid = (min + max) / 2; if (dec == min) { if (r) { max = mid; } else { min = mid; } dec = max; } else { if (r) { min = mid; } else { max = mid; } dec = min; } } int* a = new int[podajD()]; int op = (dec == min) ? max : min; int op2 = (dec == min) ? min : max; report(op2, nth); if (report(op, nth)) { //a[0] = op; return op; } else { //a[0] = op2; return op2; } //znalazlem(a); } int main() { int d = podajD(); int k = podajK(); int r = podajR(); int* pos = new int[d]; arr = new int[d]; for (int i = 0; i < d; i++) { pos[i] = 0; arr[d] = 0; } for (int i = 0; i < d; i++) { pos[i] = bin(i); } //for (int i = 0; i < d; i++) //{ // cout << pos[i] << " "; //} znalazlem(pos); return 0; } |