#include<algorithm> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> #include "cielib.h" using namespace std; typedef long long LL; typedef long double LD; #define dprintf(...) fprintf(stderr, __VA_ARGS__) int cond = 1; #define DB(X) {if(cond){cerr<<"Line:"<<__LINE__<<", "<<#X<<" = "<<X<<endl;}} int solve() { return 0; } int cur[4][505], tmp[2][505]; int d; void wypisz(int t[]) { cout << t[0]; for(int i = 1; i < d; ++i) { cout << " " << t[i]; } cout << endl; } int main() { d = podajD(); int k = podajK(); int r = podajR(); for(int i = 0; i < d; ++i) { cur[0][i] = cur[2][i] = 0; cur[1][i] = cur[3][i] = r; } bool ok = false; while (!ok) { ok = true; long long mi = 0; int ind = 0; for(int i = 0; i < d; ++i) { if (cur[0][i] + 1 >= cur[1][i]) { continue; } if (cur[1][i] - cur[0][i] > mi) { mi = cur[1][i] - cur[0][i]; ind = i; } ok = false; } if (ok) { break; } int i = ind; for(int l = 0; l < 2; ++l) { for(int j = 0; j < d; ++j) { if (i != j) { tmp[l][j] = (cur[0][j] + cur[1][j]) / 2; } else { tmp[l][j] = cur[l][j]; } } } czyCieplo(tmp[0]); /* if (i == 3) { wypisz(cur[0]); wypisz(cur[1]); cout << "tmp:\n"; wypisz(tmp[0]); wypisz(tmp[1]); } */ int m = (cur[0][i] + cur[1][i]) / 2; if (czyCieplo(tmp[1])) { cur[2][i] = m + 1; } else { if (czyCieplo(tmp[0])) { cur[3][i] = m; } else { cur[2][i] = m; cur[3][i] = m + 1; } } for(int i = 0; i < d; ++i) { cur[0][i] = cur[2][i]; cur[1][i] = cur[3][i]; } } ok = false; for(int i = 0; i < d; ++i) { if (cur[0][i] == cur[1][i]) { continue; } if (cur[0][i] > 0) { cur[0][i] -= 1; czyCieplo(cur[0]); if (czyCieplo(cur[1])) { cur[0][i] = cur[1][i]; } else { cur[0][i] += 1; cur[1][i] = cur[0][i]; } } else { cur[1][i] += 1; czyCieplo(cur[1]); if (czyCieplo(cur[0])) { cur[1][i] = cur[0][i]; } else { cur[0][i] = cur[1][i] - 1; } } } znalazlem(cur[0]); 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | #include<algorithm> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> #include "cielib.h" using namespace std; typedef long long LL; typedef long double LD; #define dprintf(...) fprintf(stderr, __VA_ARGS__) int cond = 1; #define DB(X) {if(cond){cerr<<"Line:"<<__LINE__<<", "<<#X<<" = "<<X<<endl;}} int solve() { return 0; } int cur[4][505], tmp[2][505]; int d; void wypisz(int t[]) { cout << t[0]; for(int i = 1; i < d; ++i) { cout << " " << t[i]; } cout << endl; } int main() { d = podajD(); int k = podajK(); int r = podajR(); for(int i = 0; i < d; ++i) { cur[0][i] = cur[2][i] = 0; cur[1][i] = cur[3][i] = r; } bool ok = false; while (!ok) { ok = true; long long mi = 0; int ind = 0; for(int i = 0; i < d; ++i) { if (cur[0][i] + 1 >= cur[1][i]) { continue; } if (cur[1][i] - cur[0][i] > mi) { mi = cur[1][i] - cur[0][i]; ind = i; } ok = false; } if (ok) { break; } int i = ind; for(int l = 0; l < 2; ++l) { for(int j = 0; j < d; ++j) { if (i != j) { tmp[l][j] = (cur[0][j] + cur[1][j]) / 2; } else { tmp[l][j] = cur[l][j]; } } } czyCieplo(tmp[0]); /* if (i == 3) { wypisz(cur[0]); wypisz(cur[1]); cout << "tmp:\n"; wypisz(tmp[0]); wypisz(tmp[1]); } */ int m = (cur[0][i] + cur[1][i]) / 2; if (czyCieplo(tmp[1])) { cur[2][i] = m + 1; } else { if (czyCieplo(tmp[0])) { cur[3][i] = m; } else { cur[2][i] = m; cur[3][i] = m + 1; } } for(int i = 0; i < d; ++i) { cur[0][i] = cur[2][i]; cur[1][i] = cur[3][i]; } } ok = false; for(int i = 0; i < d; ++i) { if (cur[0][i] == cur[1][i]) { continue; } if (cur[0][i] > 0) { cur[0][i] -= 1; czyCieplo(cur[0]); if (czyCieplo(cur[1])) { cur[0][i] = cur[1][i]; } else { cur[0][i] += 1; cur[1][i] = cur[0][i]; } } else { cur[1][i] += 1; czyCieplo(cur[1]); if (czyCieplo(cur[0])) { cur[1][i] = cur[0][i]; } else { cur[0][i] = cur[1][i] - 1; } } } znalazlem(cur[0]); return 0; } |