#include "cielib.h" #include <vector> #include <stdio.h> using namespace std; int sol[1000]; int cur[1000]; int d, r; void solve_dim(int dim, int begin, int end) { //printf("ENTER: %d %d\n", begin, end); if (end - begin < 7) { //Do it one by one cur[dim] = begin; czyCieplo(cur); for (int i=begin + 1;i<=end;++i) { cur[dim] = i; if (!czyCieplo(cur)) { //printf("HERE: %d %d\n", dim, i); sol[dim] = i - 1; i = end; } } if (sol[dim] == 0) sol[dim] = end; cur[dim] = 0; return; } int a1 = begin + (end - begin) / 3; int a2 = begin + 2 * (end - begin) / 3; //printf("TRYING: %d %d %d %d\n", begin, a1, a2, end); cur[dim] = a1; czyCieplo(cur); cur[dim] = a2; if(czyCieplo(cur)) solve_dim(dim, (a1 + a2) / 2 + 1, end); else solve_dim(dim, begin, (a1 + a2) / 2); } int main() { //k = podajK(); r = podajR(); d = podajD(); /*while(true) { int x[3]; int y[3]; for (int i=0;i<3;++i) scanf("%d", &x[i]); for (int i=0;i<3;++i) scanf("%d", &y[i]); czyCieplo(x); printf("%d\n", czyCieplo(y)); }*/ for (int i=0;i<d;++i) { sol[i] = 0; cur[i] = 0; } for (int i=0;i<d;++i) { solve_dim(i, 0, r); } znalazlem(sol); 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 | #include "cielib.h" #include <vector> #include <stdio.h> using namespace std; int sol[1000]; int cur[1000]; int d, r; void solve_dim(int dim, int begin, int end) { //printf("ENTER: %d %d\n", begin, end); if (end - begin < 7) { //Do it one by one cur[dim] = begin; czyCieplo(cur); for (int i=begin + 1;i<=end;++i) { cur[dim] = i; if (!czyCieplo(cur)) { //printf("HERE: %d %d\n", dim, i); sol[dim] = i - 1; i = end; } } if (sol[dim] == 0) sol[dim] = end; cur[dim] = 0; return; } int a1 = begin + (end - begin) / 3; int a2 = begin + 2 * (end - begin) / 3; //printf("TRYING: %d %d %d %d\n", begin, a1, a2, end); cur[dim] = a1; czyCieplo(cur); cur[dim] = a2; if(czyCieplo(cur)) solve_dim(dim, (a1 + a2) / 2 + 1, end); else solve_dim(dim, begin, (a1 + a2) / 2); } int main() { //k = podajK(); r = podajR(); d = podajD(); /*while(true) { int x[3]; int y[3]; for (int i=0;i<3;++i) scanf("%d", &x[i]); for (int i=0;i<3;++i) scanf("%d", &y[i]); czyCieplo(x); printf("%d\n", czyCieplo(y)); }*/ for (int i=0;i<d;++i) { sol[i] = 0; cur[i] = 0; } for (int i=0;i<d;++i) { solve_dim(i, 0, r); } znalazlem(sol); return 0; } |