#include "cielib.h" #include<iostream> #include<queue> #include<list> #include<stdio.h> #include<vector> #include<map> #include<set> using namespace std; #define ull unsigned long long int #define FOR(i,n) for(int i=0;i<n;++i) #define FORD(i,n) for(int i=(n)-1;i>=0;--i) #define znakow 26 #define dcout 0 && cout int inline min(int a,int b){return a>b?b:a;} int inline max(int a,int b){return a<b?b:a;} int main(){ int d=podajD(); int r=podajR(); int k=podajK(); int h=(r+1)/2; int w[d]; int wmin[d]; int wmax[d]; FOR(i,d){ wmin[i]=0; wmax[i]=r; w[i]=h; } while(h>1){ //dcout<<"h="<<h<<endl; FOR(i,d){ if( wmax[i] - wmin[i] < 2 )continue; int neutral=w[i]; w[i]=wmin[i]; czyCieplo(w); w[i]=wmax[i]; int a1 = czyCieplo(w); w[i]=wmin[i]; int a2 = czyCieplo(w); w[i]=neutral; //dcout<<"asked about "<<i<<", got "<<a1<<" "<<a2<<endl; if(r%2){ if(a1==0 && a2==0){ wmax[i]=wmin[i]+h; wmin[i]=wmin[i]+h-1; } if(a1==0 && a2==1){ wmax[i]=wmin[i]+h-1; } if(a1==1 && a2==0){ wmin[i]=wmin[i]+h; } }else{ if(a1==0 && a2==0){ wmax[i]=wmin[i]+h; wmin[i]=wmin[i]+h; } if(a1==0 && a2==1){ wmax[i]=wmin[i]+h-1; } if(a1==1 && a2==0){ wmin[i]=wmin[i]+h+1; } } } r=(r-1)/2; h=(r+1)/2; FOR(i,d){ if( wmax[i] - wmin[i] < 2 ){ w[i]=wmin[i]; }else{ w[i]=wmin[i]+h; } } //dcout<<"wmin=[ ";FOR(i,d)dcout<<wmin[i]<<", ";dcout<<endl; //dcout<<"wmax=[ ";FOR(i,d)dcout<<wmax[i]<<", ";dcout<<endl; //dcout<<"w =[ ";FOR(i,d)dcout<<w[i]<<", ";dcout<<endl; } FOR(i,d){ if(wmax[i]==wmin[i]){ w[i]=wmin[i];// to be sure continue; } if(wmin[i]+1==wmax[i]){ if(wmin[i]) --wmin[i]; else ++wmax[i]; } w[i]=wmin[i]; czyCieplo(w); w[i]=wmax[i]; int a1 = czyCieplo(w); w[i]=wmin[i]; int a2 = czyCieplo(w); if(a1==0 && a2==0){ w[i]=wmin[i]+1; } if(a1==0 && a2==1){ w[i]=wmin[i]; } if(a1==1 && a2==0){ w[i]=wmin[i]+2; } } znalazlem(w); 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 | #include "cielib.h" #include<iostream> #include<queue> #include<list> #include<stdio.h> #include<vector> #include<map> #include<set> using namespace std; #define ull unsigned long long int #define FOR(i,n) for(int i=0;i<n;++i) #define FORD(i,n) for(int i=(n)-1;i>=0;--i) #define znakow 26 #define dcout 0 && cout int inline min(int a,int b){return a>b?b:a;} int inline max(int a,int b){return a<b?b:a;} int main(){ int d=podajD(); int r=podajR(); int k=podajK(); int h=(r+1)/2; int w[d]; int wmin[d]; int wmax[d]; FOR(i,d){ wmin[i]=0; wmax[i]=r; w[i]=h; } while(h>1){ //dcout<<"h="<<h<<endl; FOR(i,d){ if( wmax[i] - wmin[i] < 2 )continue; int neutral=w[i]; w[i]=wmin[i]; czyCieplo(w); w[i]=wmax[i]; int a1 = czyCieplo(w); w[i]=wmin[i]; int a2 = czyCieplo(w); w[i]=neutral; //dcout<<"asked about "<<i<<", got "<<a1<<" "<<a2<<endl; if(r%2){ if(a1==0 && a2==0){ wmax[i]=wmin[i]+h; wmin[i]=wmin[i]+h-1; } if(a1==0 && a2==1){ wmax[i]=wmin[i]+h-1; } if(a1==1 && a2==0){ wmin[i]=wmin[i]+h; } }else{ if(a1==0 && a2==0){ wmax[i]=wmin[i]+h; wmin[i]=wmin[i]+h; } if(a1==0 && a2==1){ wmax[i]=wmin[i]+h-1; } if(a1==1 && a2==0){ wmin[i]=wmin[i]+h+1; } } } r=(r-1)/2; h=(r+1)/2; FOR(i,d){ if( wmax[i] - wmin[i] < 2 ){ w[i]=wmin[i]; }else{ w[i]=wmin[i]+h; } } //dcout<<"wmin=[ ";FOR(i,d)dcout<<wmin[i]<<", ";dcout<<endl; //dcout<<"wmax=[ ";FOR(i,d)dcout<<wmax[i]<<", ";dcout<<endl; //dcout<<"w =[ ";FOR(i,d)dcout<<w[i]<<", ";dcout<<endl; } FOR(i,d){ if(wmax[i]==wmin[i]){ w[i]=wmin[i];// to be sure continue; } if(wmin[i]+1==wmax[i]){ if(wmin[i]) --wmin[i]; else ++wmax[i]; } w[i]=wmin[i]; czyCieplo(w); w[i]=wmax[i]; int a1 = czyCieplo(w); w[i]=wmin[i]; int a2 = czyCieplo(w); if(a1==0 && a2==0){ w[i]=wmin[i]+1; } if(a1==0 && a2==1){ w[i]=wmin[i]; } if(a1==1 && a2==0){ w[i]=wmin[i]+2; } } znalazlem(w); return 0; } |