#include "cielib.h" #include <bits/stdc++.h> using namespace std; #define FOR(i,n) for(int i=0; i < int(n); ++i) #define FO(i,a,b) for(int i=int(a); i<int(b); ++i) typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; #define siz size()*1LL #define fi first #define se second #define ASS assert #define remin(a,b) a=min(a,b) #define remax(a,b) a=max(a,b) #define ALL(c) (c).begin(), (c).end() #define NL '\n' int main(){ int D = podajD(); int K = podajK(); int R = podajR(); int mi[D], ma[D]; FOR(i,D) mi[i] = 0; FOR(i,D) ma[i] = R; int t[D]; FOR(iter,32){ FOR(d,D){ if(mi[d] + 1 >= ma[d]) continue; FOR(dd,D) t[dd] = (mi[dd] + ma[dd])/2; t[d] = mi[d]; czyCieplo(t); t[d] = ma[d]; int r = czyCieplo(t); if(r){ mi[d] = (mi[d] + ma[d]) / 2; } else{ ma[d] = (mi[d] + ma[d] + 1) / 2; } } } FOR(d,D){ if(mi[d] == ma[d]) continue; FOR(dd,D) t[dd] = mi[dd]; if(mi[d] > 0){ t[d] = mi[d]-1; czyCieplo(t); t[d] = ma[d]; if(czyCieplo(t)){ mi[d] = ma[d]; } else{ ma[d] = mi[d]; } } else{ t[d] = ma[d]+1; czyCieplo(t); t[d] = mi[d]; if(czyCieplo(t)){ ma[d] = mi[d]; } else{ mi[d] = ma[d]; } } } znalazlem(mi); 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 | #include "cielib.h" #include <bits/stdc++.h> using namespace std; #define FOR(i,n) for(int i=0; i < int(n); ++i) #define FO(i,a,b) for(int i=int(a); i<int(b); ++i) typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; #define siz size()*1LL #define fi first #define se second #define ASS assert #define remin(a,b) a=min(a,b) #define remax(a,b) a=max(a,b) #define ALL(c) (c).begin(), (c).end() #define NL '\n' int main(){ int D = podajD(); int K = podajK(); int R = podajR(); int mi[D], ma[D]; FOR(i,D) mi[i] = 0; FOR(i,D) ma[i] = R; int t[D]; FOR(iter,32){ FOR(d,D){ if(mi[d] + 1 >= ma[d]) continue; FOR(dd,D) t[dd] = (mi[dd] + ma[dd])/2; t[d] = mi[d]; czyCieplo(t); t[d] = ma[d]; int r = czyCieplo(t); if(r){ mi[d] = (mi[d] + ma[d]) / 2; } else{ ma[d] = (mi[d] + ma[d] + 1) / 2; } } } FOR(d,D){ if(mi[d] == ma[d]) continue; FOR(dd,D) t[dd] = mi[dd]; if(mi[d] > 0){ t[d] = mi[d]-1; czyCieplo(t); t[d] = ma[d]; if(czyCieplo(t)){ mi[d] = ma[d]; } else{ ma[d] = mi[d]; } } else{ t[d] = ma[d]+1; czyCieplo(t); t[d] = mi[d]; if(czyCieplo(t)){ ma[d] = mi[d]; } else{ mi[d] = ma[d]; } } } znalazlem(mi); return 0; } |