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
105
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include "cielib.h"

typedef unsigned long long big;
typedef unsigned int var;

#define COPY(a,b) std::copy(a, a+d, b);
#define DEBUG(...) if(debug) fprintf(stderr, __VA_ARGS__);
#define PRINT(...) if(debug) fprintf(stderr, __VA_ARGS__);
//#define DEBUG(...) ;
template <typename T>
void zeroMemory(T& t)
{
  memset(&t, 0, sizeof(t));
  }
bool debug = false;

int last[500];
int now[500];
int peek[500];
int rangeU[500];
int rangeD[500];
int happy[500];
var happyDim = 0;
long long happyNow = 0;

var ind;
var range;

var d;
var r; 
var k; 

void start()
{
   for (var i = 0 ; i < d; ++i)
   {
     //now[i]= r/2;
     now[i]= 0;
   }

   czyCieplo(now); // init temp
   k--;

   for (var i = 0 ; i < d; ++i)
   {
     rangeU[i]= r;
     rangeD[i]= 0;
   }
}


bool krok()
{
    COPY(now,peek);
    for (var i = 0; i < d; ++i)
    {
        if(happy[i] > 0)
            continue;
        var delta = 1;
        if (now[i]+delta > r)
            continue;
        peek[i] = now[i]+delta;

        if(czyCieplo(peek)) 
        {
           COPY(peek,now);
          //  now[i] = peek[i];
            rangeD[i] = now[i];
            zeroMemory(happy);
            k--;
            return true;
        }
        else
        {
            // zmiana zwiekszyla odleglosc!! ten wymiar przestal byc najdalszy
            happy[i] = 1;
        }
    }
    return false; // nie moze byc cieplej
}

#ifndef UT

int main()
{
    d = podajD();
    r = podajR();
    k = podajK();

    start();

    while (krok() && k);

	znalazlem(now); 
  return 0;
}

#endif