#include "cielib.h"
#include <cassert>
#include <cstdio>
#include <algorithm>
#define fru(j,n) for(int j=0;j<(n);++j)
const int MAXD=505;
int G[MAXD],D[MAXD];
int main() {
	 srand(42);
	 int d = podajD(),r=podajR();
	 int t[d];
	 fru(i,d) G[i]=r;
	 fru(i,d) D[i]=0;
	 int ile=0;
	 while(ile!=d) fru(e,d) if(G[e]!=D[e]){
		  int prob=0;
		  while(1){
				++prob;
				bool zle=0;
				fru(i,d) {
					 if(D[i]==G[i]) t[i]=G[i];
					 else{
						 if((G[i]-D[i])%2==1) t[i]=(G[i]+D[i]+rand()%2)/2;
						 else {
							  if(prob>8) t[i]=(G[i]+D[i]+rand()%3-1)/2;
							  else t[i]=(G[i]+D[i]+rand()%2)/2;
						 }
					 }
				}
				int a=D[e],b=G[e];
				assert(a<b);
				t[e]=a;
				czyCieplo(t);
				
				t[e]=b;
				bool x=czyCieplo(t);
				if((b-a)%2==0){
//					 printf("pytalem o "); fru(i,d) printf("%d ",t[i]); printf(" i dostalem %d\n",x);
					 if(x) D[e]=(a+b)/2+1;
					 else G[e]=(a+b)/2;
				}
				else{
					 if(x) D[e]=(a+b)/2+1;
					 else{
						  t[e]=a;
						  bool y=czyCieplo(t);
						  if(y==1) G[e]=(a+b)/2;
						  else {
								zle=1;
//								printf("nie udalo mi sie, ile = %d\n",ile); fru(i,d) printf("[%d,%d] ",D[i],G[i]); puts("");
//								printf("probowalem z :\n"); fru(i,d) printf("%d ",t[i]); puts("");
						  }
					 }
				}
				if(D[e]==G[e]) ++ile;
				if(zle==0) break;
		  }
//		  printf("teraz dla wymiaru %d mam [%d,%d]\n",e,D[e],G[e]);
//		  if(!sprawdz(D,G)) exit(1);
	 }
	 fru(i,d) t[i]=G[i];
	 znalazlem(t);
}
        | 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 | #include "cielib.h" #include <cassert> #include <cstdio> #include <algorithm> #define fru(j,n) for(int j=0;j<(n);++j) const int MAXD=505; int G[MAXD],D[MAXD]; int main() { srand(42); int d = podajD(),r=podajR(); int t[d]; fru(i,d) G[i]=r; fru(i,d) D[i]=0; int ile=0; while(ile!=d) fru(e,d) if(G[e]!=D[e]){ int prob=0; while(1){ ++prob; bool zle=0; fru(i,d) { if(D[i]==G[i]) t[i]=G[i]; else{ if((G[i]-D[i])%2==1) t[i]=(G[i]+D[i]+rand()%2)/2; else { if(prob>8) t[i]=(G[i]+D[i]+rand()%3-1)/2; else t[i]=(G[i]+D[i]+rand()%2)/2; } } } int a=D[e],b=G[e]; assert(a<b); t[e]=a; czyCieplo(t); t[e]=b; bool x=czyCieplo(t); if((b-a)%2==0){ // printf("pytalem o "); fru(i,d) printf("%d ",t[i]); printf(" i dostalem %d\n",x); if(x) D[e]=(a+b)/2+1; else G[e]=(a+b)/2; } else{ if(x) D[e]=(a+b)/2+1; else{ t[e]=a; bool y=czyCieplo(t); if(y==1) G[e]=(a+b)/2; else { zle=1; // printf("nie udalo mi sie, ile = %d\n",ile); fru(i,d) printf("[%d,%d] ",D[i],G[i]); puts(""); // printf("probowalem z :\n"); fru(i,d) printf("%d ",t[i]); puts(""); } } } if(D[e]==G[e]) ++ile; if(zle==0) break; } // printf("teraz dla wymiaru %d mam [%d,%d]\n",e,D[e],G[e]); // if(!sprawdz(D,G)) exit(1); } fru(i,d) t[i]=G[i]; znalazlem(t); } | 
 
            
         English
                    English