#include "cielib.h" #include <vector> const int N = 500 + 10; int main() { int d = podajD(), m = podajR(); static int l[N], r[N]; for (int i = 0; i < d; ++i) l[i] = 0, r[i] = m; for (int cur = m; cur > 2;) { static int temp[N]; for (int i = 0; i < d; ++i) temp[i] = (l[i] + r[i]) / 2; cur = (cur + 1) / 2; for (int i = 0; i < d; ++i) { static int val[N]; for (int j = 0; j < d; ++j) val[j] = temp[j]; val[i] = l[i]; czyCieplo(val); val[i] = r[i]; if (czyCieplo(val)) l[i] = r[i] - cur; else r[i] = l[i] + cur; } } static int res[N], val[N]; for (int i = 0; i < d; ++i) { for (int j = 0; j < d; ++j) if (j != i) val[j] = (l[j] + r[j]) / 2; int a = l[i], b = (l[i] + r[i]) / 2, c = r[i]; val[i] = a; czyCieplo(val); val[i] = c; int x = czyCieplo(val); val[i] = c; czyCieplo(val); val[i] = a; int y = czyCieplo(val); if (!x && !y) res[i] = b; else if (x) res[i] = c; else res[i] = a; } znalazlem(res); 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 | #include "cielib.h" #include <vector> const int N = 500 + 10; int main() { int d = podajD(), m = podajR(); static int l[N], r[N]; for (int i = 0; i < d; ++i) l[i] = 0, r[i] = m; for (int cur = m; cur > 2;) { static int temp[N]; for (int i = 0; i < d; ++i) temp[i] = (l[i] + r[i]) / 2; cur = (cur + 1) / 2; for (int i = 0; i < d; ++i) { static int val[N]; for (int j = 0; j < d; ++j) val[j] = temp[j]; val[i] = l[i]; czyCieplo(val); val[i] = r[i]; if (czyCieplo(val)) l[i] = r[i] - cur; else r[i] = l[i] + cur; } } static int res[N], val[N]; for (int i = 0; i < d; ++i) { for (int j = 0; j < d; ++j) if (j != i) val[j] = (l[j] + r[j]) / 2; int a = l[i], b = (l[i] + r[i]) / 2, c = r[i]; val[i] = a; czyCieplo(val); val[i] = c; int x = czyCieplo(val); val[i] = c; czyCieplo(val); val[i] = a; int y = czyCieplo(val); if (!x && !y) res[i] = b; else if (x) res[i] = c; else res[i] = a; } znalazlem(res); return 0; } |