#include <bits/stdc++.h> #include <stdint.h> #include "cielib.h" using namespace std; int main() { int d = podajD(); int r = podajR(); int p0[512] = {0}; int p1[512]; int q[512]; for(int i = 0; i < d; ++i) p1[i] = r; int u = r; while(u) { int md = 0; for(int i = 0; i < d; ++i) { q[i] = (p0[i] + p1[i]) / 2; md = max(md, q[i] - p0[i]); } // cerr << "q = "; for(int i = 0; i < d; ++i) cerr << q[i] << ' '; cerr << '\n'; for(int i = 0; i < d; ++i) { if(p1[i] - p0[i] > 1) { int t = q[i]; q[i] = p0[i]; czyCieplo(q); q[i] = p1[i]; if(czyCieplo(q)) { p0[i] = (p0[i] + p1[i]) / 2; } else { p1[i] = (p0[i] + p1[i] + 1) / 2; } q[i] = t; // cerr << i << ": " << p0[i] << ' ' << p1[i] << '\n'; } else if(p1[i] - p0[i] == 1 and u <= 1) { if(p0[i] == 0) { q[i] = p1[i] + 1; czyCieplo(q); q[i] = p1[i]; if(czyCieplo(q)) { p1[i] = p0[i]; } else { p0[i] = p1[i]; } } else { q[i] = p0[i] - 1; czyCieplo(q); q[i] = p0[i]; if(czyCieplo(q)) { p0[i] = p1[i]; } else { p1[i] = p0[i]; } } } } u = 0; for(int i = 0; i < d; ++i) u = max(u, p1[i] - p0[i]); } cerr << "ans = "; for(int i = 0; i < d; ++i) cerr << p0[i] << ' '; cerr << '\n'; znalazlem(p0); 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 | #include <bits/stdc++.h> #include <stdint.h> #include "cielib.h" using namespace std; int main() { int d = podajD(); int r = podajR(); int p0[512] = {0}; int p1[512]; int q[512]; for(int i = 0; i < d; ++i) p1[i] = r; int u = r; while(u) { int md = 0; for(int i = 0; i < d; ++i) { q[i] = (p0[i] + p1[i]) / 2; md = max(md, q[i] - p0[i]); } // cerr << "q = "; for(int i = 0; i < d; ++i) cerr << q[i] << ' '; cerr << '\n'; for(int i = 0; i < d; ++i) { if(p1[i] - p0[i] > 1) { int t = q[i]; q[i] = p0[i]; czyCieplo(q); q[i] = p1[i]; if(czyCieplo(q)) { p0[i] = (p0[i] + p1[i]) / 2; } else { p1[i] = (p0[i] + p1[i] + 1) / 2; } q[i] = t; // cerr << i << ": " << p0[i] << ' ' << p1[i] << '\n'; } else if(p1[i] - p0[i] == 1 and u <= 1) { if(p0[i] == 0) { q[i] = p1[i] + 1; czyCieplo(q); q[i] = p1[i]; if(czyCieplo(q)) { p1[i] = p0[i]; } else { p0[i] = p1[i]; } } else { q[i] = p0[i] - 1; czyCieplo(q); q[i] = p0[i]; if(czyCieplo(q)) { p0[i] = p1[i]; } else { p1[i] = p0[i]; } } } } u = 0; for(int i = 0; i < d; ++i) u = max(u, p1[i] - p0[i]); } cerr << "ans = "; for(int i = 0; i < d; ++i) cerr << p0[i] << ' '; cerr << '\n'; znalazlem(p0); return 0; } |