#include <vector>
#include "cielib.h"
using namespace std;
int main() {
	int d = podajD();
	int k = podajK();
	int r = podajR();
	vector<vector<int> > a(2, vector<int>(d, 0));
	int t[d];
	for (int i = 0; i < d; i++) {
		a[1][i] = r;
		t[i] = 0;
	}
	int dir = 1;
	czyCieplo(t);
	int kc = 1;
	int dc = 0;
	int done = 0;
	int ch = 0;
	while (kc < k) {
		int r1, r2;
		bool dirchange = true;
		for (int i = 0; i < d; i++) {
			if (a[0][i] == a[1][i]) continue;
			kc += 2;
			if (kc > k) break;
			t[i] = a[dir][i];
			r1 = czyCieplo(t);
			if (r1) {
				a[1-dir][i] = (a[0][i] + a[1][i] + dir) / 2;
			}
			t[i] = a[1-dir][i];
			r2 = czyCieplo(t);
			if (r2) {
				a[dir][i] = (a[0][i] + a[1][i] + 1 - dir) / 2;
			}
			if (r1 || r2) {
				dirchange = false;
			}
			if (a[0][i] == a[1][i]) done++;
		}
		if (done == d) break;
		if (dirchange) {
			if (ch) {
				pair<int, int> ll;
				ll.first = 0;
				ll.second = a[1][0] - a[0][0];
				for (int i = 1; i < d; i++) {
					int l = a[1][i] - a[0][i];
					if (l > ll.second) {
						ll.first = i;
						ll.second = l;
					}
				}
				done++;
				a[0][ll.first] = a[1][ll.first] = (a[0][ll.first] + a[1][ll.first]) / 2;
				t[ll.first] = a[0][ll.first];
				ch = 0;
			} else {
				ch++;
				dir = 1 - dir;
				for (int i = 0; i < d; i++) {
					t[i] = a[1-dir][i];
				}
			}
		} else {
			ch = 0;
		}
	}
	znalazlem(t);
	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 85 86 87 88 89 90 91 | #include <vector> #include "cielib.h" using namespace std; int main() { int d = podajD(); int k = podajK(); int r = podajR(); vector<vector<int> > a(2, vector<int>(d, 0)); int t[d]; for (int i = 0; i < d; i++) { a[1][i] = r; t[i] = 0; } int dir = 1; czyCieplo(t); int kc = 1; int dc = 0; int done = 0; int ch = 0; while (kc < k) { int r1, r2; bool dirchange = true; for (int i = 0; i < d; i++) { if (a[0][i] == a[1][i]) continue; kc += 2; if (kc > k) break; t[i] = a[dir][i]; r1 = czyCieplo(t); if (r1) { a[1-dir][i] = (a[0][i] + a[1][i] + dir) / 2; } t[i] = a[1-dir][i]; r2 = czyCieplo(t); if (r2) { a[dir][i] = (a[0][i] + a[1][i] + 1 - dir) / 2; } if (r1 || r2) { dirchange = false; } if (a[0][i] == a[1][i]) done++; } if (done == d) break; if (dirchange) { if (ch) { pair<int, int> ll; ll.first = 0; ll.second = a[1][0] - a[0][0]; for (int i = 1; i < d; i++) { int l = a[1][i] - a[0][i]; if (l > ll.second) { ll.first = i; ll.second = l; } } done++; a[0][ll.first] = a[1][ll.first] = (a[0][ll.first] + a[1][ll.first]) / 2; t[ll.first] = a[0][ll.first]; ch = 0; } else { ch++; dir = 1 - dir; for (int i = 0; i < d; i++) { t[i] = a[1-dir][i]; } } } else { ch = 0; } } znalazlem(t); return 0; } | 
 
            
         English
                    English