#include "cielib.h"
#include <cstdio>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define pb push_back
#define FORI for(int i=0; i<d; ++i)
int d, k, r;
vi lastQ;
bool lepiej(vi& a, vi& b) {
  FORI if(a[i] < 0 || a[i] > r || b[i] < 0 || b[i] > r) return false;
  if(a != lastQ)
    czyCieplo(&a[0]);
  lastQ = b;
  return czyCieplo(&b[0]);
}
bool inc(vi& t) {
  for(int i=0; i<d; ++i)
    if(t[i] == -1) t[i] = 2;
  bool res = false;
  for(int i=0; i<=d; ++i) {
    if(i==d) break;
    ++t[i];
    if(t[i] <= 2) {res = true; break;}
    else t[i] = 0;
  }
  for(int i=0; i<d; ++i)
    if(t[i] == 2) t[i] = -1;
  return res;
}
void dbl(vi& t) { for(int i=0; i<d; ++i) t[i] *= 2; }
vi plus(const vi& x, const vi& t) {
  vi p(d, 0);
  for(int i=0; i<d; ++i)
    p[i] = x[i] + t[i];
  return p;
}
vi szukaj(vi x) {
  while(true) { // Az nie da sie poprawic
    bool poprawione = false;
    vi t(d, 0);
    while(inc(t)) { // Dla kazdego kierunku
      //      printf("t = "); FORI printf("\t%d", t[i]); puts("");
      vi gt = t;
      vi next = plus(x, gt);
      while(lepiej(x, next)) { // Dopoki kierunek dziala
        poprawione = true;
        x = next;
        //FORI printf("\t%d", x[i]); puts("");
        dbl(gt);
        next = plus(x, gt);
      }
      if(poprawione) break;
    }
    if(!poprawione) return x;
  }
}
int main() {
  d = podajD(); k = podajK(); r = podajR();
  vi wynik = szukaj(vi(d, 0));
  znalazlem(&wynik[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 | #include "cielib.h" #include <cstdio> #include <vector> using namespace std; typedef vector<int> vi; #define pb push_back #define FORI for(int i=0; i<d; ++i) int d, k, r; vi lastQ; bool lepiej(vi& a, vi& b) { FORI if(a[i] < 0 || a[i] > r || b[i] < 0 || b[i] > r) return false; if(a != lastQ) czyCieplo(&a[0]); lastQ = b; return czyCieplo(&b[0]); } bool inc(vi& t) { for(int i=0; i<d; ++i) if(t[i] == -1) t[i] = 2; bool res = false; for(int i=0; i<=d; ++i) { if(i==d) break; ++t[i]; if(t[i] <= 2) {res = true; break;} else t[i] = 0; } for(int i=0; i<d; ++i) if(t[i] == 2) t[i] = -1; return res; } void dbl(vi& t) { for(int i=0; i<d; ++i) t[i] *= 2; } vi plus(const vi& x, const vi& t) { vi p(d, 0); for(int i=0; i<d; ++i) p[i] = x[i] + t[i]; return p; } vi szukaj(vi x) { while(true) { // Az nie da sie poprawic bool poprawione = false; vi t(d, 0); while(inc(t)) { // Dla kazdego kierunku // printf("t = "); FORI printf("\t%d", t[i]); puts(""); vi gt = t; vi next = plus(x, gt); while(lepiej(x, next)) { // Dopoki kierunek dziala poprawione = true; x = next; //FORI printf("\t%d", x[i]); puts(""); dbl(gt); next = plus(x, gt); } if(poprawione) break; } if(!poprawione) return x; } } int main() { d = podajD(); k = podajK(); r = podajR(); vi wynik = szukaj(vi(d, 0)); znalazlem(&wynik[0]); } | 
 
            
         English
                    English