#include "cielib.h" int ask(int &c, int *t) { ++c; return czyCieplo(t); } int main() { int D, R; int r; int pos[500] = {}, t[500] = {}; int c = 0; D = podajD(); R = podajR(); r = R; while (r > 0) { for (int i = 0; i < D; ++i) t[i] = pos[i] + (r/2); for (int i = 0; i < D; ++i) { int old = t[i]; if (r > 1) { t[i] = pos[i]; ask(c,t); t[i] = pos[i] + r; if (ask(c,t)) { pos[i] = pos[i] + r - (r+1)/2; } } else { if (t[i] + 2 <= R) { t[i] += 2; ask(c,t); t[i] = old; if (!ask(c,t)) pos[i] += 1; } else { t[i] -= 1; ask(c,t); t[i] += 2; if (ask(c,t)) { pos[i] += 1; } } } t[i] = old; } if (r > 1) r = (r+1)/2; else r = 0; } 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 | #include "cielib.h" int ask(int &c, int *t) { ++c; return czyCieplo(t); } int main() { int D, R; int r; int pos[500] = {}, t[500] = {}; int c = 0; D = podajD(); R = podajR(); r = R; while (r > 0) { for (int i = 0; i < D; ++i) t[i] = pos[i] + (r/2); for (int i = 0; i < D; ++i) { int old = t[i]; if (r > 1) { t[i] = pos[i]; ask(c,t); t[i] = pos[i] + r; if (ask(c,t)) { pos[i] = pos[i] + r - (r+1)/2; } } else { if (t[i] + 2 <= R) { t[i] += 2; ask(c,t); t[i] = old; if (!ask(c,t)) pos[i] += 1; } else { t[i] -= 1; ask(c,t); t[i] += 2; if (ask(c,t)) { pos[i] += 1; } } } t[i] = old; } if (r > 1) r = (r+1)/2; else r = 0; } znalazlem(pos); return 0; } |