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
#include "cielib.h"

#include <iostream>
#include <math.h>
using namespace std;
int main() {


	int pos[500]={};
	int searchR=podajR();
	for(int d=0;d<podajD();d++){
		//int index=0;
		//pos[i]+=searchR;
		//searchR/=2;

		//int prevval=0;
		//int dir=1;
		int k=0;
		while(searchR>=1){
			k++;
			czyCieplo(pos);
			for(int i=0;i<podajD();i++){
				if(i+1!=d)
					pos[i]+=searchR;
				else
					pos[i]-=searchR;
			}
			//cout<<" {";
			for(int j=0;j<podajD();j++){
				cout<<pos[j]<<",";
			}
			//cout<<"}";
			int val=czyCieplo(pos);
			for(int i=0;i<podajD();i++){
				if(i+1!=d)
					pos[i]-=searchR;
				else
					pos[i]+=searchR;
			}
			if(val==1){

				for(int i=0;i<podajD();i++){
					if(i+1!=d)
						pos[i]+=(searchR+1)/2;
					else
						pos[i]-=(searchR+1)/2;
				}
			}
			//cout<<" "<<aa<<" "<<(val==1)<<" "<<k<<" {";
			for(int j=0;j<podajD();j++){
				cout<<pos[j]<<",";
			}
			searchR/=2;
			//cout<<"} ";
			/*k++;
			pos[i]+=searchR*dir;
			int val=czyCieplo(pos);
			if(val==1){
				if(podajR()%2==1){
					pos++;
				}
			}
			searchR/=2;
			if()
			dir*=-1;
			prevval=val;*/
		}



		if(d!=podajD()-1){
			for(int i=0;i<podajD();i++){
				if(i+1!=d)
					pos[i]+=1;
				else
					pos[i]-=1;
			}
			bool inbet=czyCieplo(pos)==0;
			for(int i=0;i<podajD();i++){
				if(i+1!=d)
					pos[i]-=1;
				else
					pos[i]+=1;
			}
			inbet=inbet&&czyCieplo(pos)==0;
			//cout<<"inbet: "<<inbet;
			searchR=podajR()-fabs((pos[d]+(inbet?0.5:0)-((double)podajR()/(double)2)))*2;
			//cout<<"final: "<<searchR<<pos[0]<<" "<<pos[1];
			for(int i=0;i<podajD();i++){
				if(i==d)
					pos[i]+=searchR/2;
				else{
					pos[i]-=searchR/2;
				}
			}
			if(inbet){
				pos[d+1]++;
			}
			//cout<<"final: "<<searchR<<pos[0]<<" "<<pos[1]<<" "<<pos[2];
		}
	}
	znalazlem(pos);
	return 0;
}