#include <cstdio>
using namespace std;
#include "cielib.h"
int main()
{
int d = podajD();
int k = podajK();
int r = podajR();
int * pozycja = new int [d];
int * lower = new int [d];
int * upper = new int [d];
for( int i=0 ; i<d ; i++ )
{
lower[i]=0;
upper[i]=r;
}
while(1)
{
int index=0;
for( int i=1 ; i<d ; i++ )
{
if( upper[i]-lower[i] > upper[index]-lower[index] )
index = i;
}
if( upper[index]-lower[index]<=1 )
break;
for( int i=0 ; i<d ; i++ )
pozycja[i]=(lower[i]+upper[i])/2;
pozycja[index]=lower[index];
czyCieplo(pozycja);
pozycja[index]=upper[index];
int answer = czyCieplo(pozycja);
if( answer==0 )
upper[index] = (lower[index]+upper[index]+1)/2;
else
lower[index] = (lower[index]+upper[index]+1)/2+1;
}
for( int i=0 ; i<d ; i++ )
pozycja[i]=lower[i];
for( int i=0 ; i<d ; i++ )
{
if( lower[i]==upper[i] )
continue;
if( lower[i]>0 )
{
pozycja[i]=lower[i]-1;
czyCieplo(pozycja);
pozycja[i]=upper[i];
int answer = czyCieplo(pozycja);
if( answer==0 )
upper[i]=pozycja[i]=lower[i];
else
lower[i]=pozycja[i]=upper[i];
}
else
{
pozycja[i]=upper[i]+1;
czyCieplo(pozycja);
pozycja[i]=lower[i];
int answer = czyCieplo(pozycja);
if( answer==0 )
lower[i]=pozycja[i]=upper[i];
else
upper[i]=pozycja[i]=lower[i];
}
}
znalazlem(pozycja);
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 | #include <cstdio> using namespace std; #include "cielib.h" int main() { int d = podajD(); int k = podajK(); int r = podajR(); int * pozycja = new int [d]; int * lower = new int [d]; int * upper = new int [d]; for( int i=0 ; i<d ; i++ ) { lower[i]=0; upper[i]=r; } while(1) { int index=0; for( int i=1 ; i<d ; i++ ) { if( upper[i]-lower[i] > upper[index]-lower[index] ) index = i; } if( upper[index]-lower[index]<=1 ) break; for( int i=0 ; i<d ; i++ ) pozycja[i]=(lower[i]+upper[i])/2; pozycja[index]=lower[index]; czyCieplo(pozycja); pozycja[index]=upper[index]; int answer = czyCieplo(pozycja); if( answer==0 ) upper[index] = (lower[index]+upper[index]+1)/2; else lower[index] = (lower[index]+upper[index]+1)/2+1; } for( int i=0 ; i<d ; i++ ) pozycja[i]=lower[i]; for( int i=0 ; i<d ; i++ ) { if( lower[i]==upper[i] ) continue; if( lower[i]>0 ) { pozycja[i]=lower[i]-1; czyCieplo(pozycja); pozycja[i]=upper[i]; int answer = czyCieplo(pozycja); if( answer==0 ) upper[i]=pozycja[i]=lower[i]; else lower[i]=pozycja[i]=upper[i]; } else { pozycja[i]=upper[i]+1; czyCieplo(pozycja); pozycja[i]=lower[i]; int answer = czyCieplo(pozycja); if( answer==0 ) lower[i]=pozycja[i]=upper[i]; else upper[i]=pozycja[i]=lower[i]; } } znalazlem(pozycja); return 0; } |
English