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
106
107
108
109
110
111
112
113
114
115
#include<bits/stdc++.h>
#define PII pair<int,int>
#define f first
#define s second
#define VI vector<int>
#define LL long long
#define MP make_pair
#define LD long double
#define PB push_back
#define ALL(V) V.begin(),V.end()
#define abs(x) max((x),-(x))
#define PDD pair<LD,LD> 
#define VPII vector< PII > 
#define siz(V) ((int)V.size())
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define FORD(x, b, e) for(int x=b;x>=(e);x--)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
using namespace std;

#include "cielib.h"

const int MXD = 500;

int mi[MXD];
int mx[MXD];
int acc[MXD];

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

void ustawsr()
  {
  REP(i, d)
    acc[i] = (mi[i] + mx[i])/2;
  }
int mxsro(int a, int b)
  {
  return (b-a+1)/2; 
  }
int main()
{
REP(i, d)
  {
  mi[i] = 0;
  mx[i] = r;
  }
  
if(r % 2 == 1)// napraw niepatrzyste
  {
  int odl = r/2 + 1;
  int ust = r/2;
  REP(i, d)
    {
    ustawsr();
    acc[i] = acc[i] - ust;
    czyCieplo(acc);
    acc[i] = acc[i] + 2*ust;
    if(czyCieplo(acc))
      mi[i]++;
    else
      mx[i]--;
    }  
  }

while(1)
  {
  int mxodl = 0;
  REP(j, d)
    {
    if((mx[j] - mi[j]) % 2 == 1)
      {
      if(mx[j] < r)mx[j]++;
      else if(mi[j] > 0)mi[j]--;
      else assert(false);
      }
    maxi(mxodl, mxsro(mi[j], mx[j]));
    }
  if(mxodl == 0)break;
  REP(i, d)
    {  
/*    cerr<<" mxodl: "<<mxodl<<endl;
    REP(j, d)
      cerr<<mi[j]<<" "<<mx[j]<<endl;
    cerr<<endl;*/
    
    if(mi[i] == mx[i])continue;
    
    ustawsr();    
    acc[i] = acc[i] - mxodl;
    czyCieplo(acc); // 1
    acc[i] = acc[i] + 2 * mxodl;
    if(czyCieplo(acc)) // 2
      {
      mi[i] += mxodl + 1;
      }
    else
      {
      acc[i] = acc[i] - 2 * mxodl;
      if(czyCieplo(acc)) // 3
        {
        mx[i] -= mxodl + 1;
        }
     else
        {
        mi[i] = mx[i] = acc[i] + mxodl;
        }
      }
    }
  }
REP(i, d)acc[i] = mi[i];
znalazlem(acc);
}