Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: dorijan1
- TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
- LANG: C++11
- */
- #include <bits/stdc++.h>
- using namespace std;
- const int MOD=1000000007;
- const char en='\n';
- typedef long long int ll;
- int t;
- int gi,fi,bi,hi,fight,ge,meg,mef,mei,meb,meh;
- int disc;
- double gt,ft;
- int cosgf[1001][1001];
- int costf[1001][1001];
- int bre[1001][1001];
- int fig[][4]={{0,0,0,0},
- {0,0,0,0},
- {0,0,0,0},
- {0,3,10,21},
- {0,0,0,0},
- {0,5,16,33},
- {0,0,0,0},
- {0,0,0,0},
- {0,3,8,15},
- {0,0,0,0},
- {0,10,30,60},
- {0,0,0,0},
- {0,3,7,12},
- {0,3,12,27}};
- int cost1(int go,int fo,int fi,int bi,int hi,int mg,int mf,int mi,int mb,int mh)
- {
- int el=(go<0?0:cosgf[go][mg])+(fo<0?0:costf[mf][fo])+(fi<0?0:fig[mi][fi])+((bi<0)?0:bre[bi][mb])+((hi<0)?0:bre[hi][mh]);
- return el;
- }
- int cost(int go,int fo,int fi,int bi,int hi,int mg,int mf,int mi,int mb,int mh)
- {
- return min((((go<0?0:cosgf[go][mg])+(fo<0?0:costf[mf][fo])+(fi<0?0:fig[mi][fi])+((bi<0)?0:bre[bi][mb])+((hi<0)?0:bre[hi][mh]))*disc+999)/1000,
- (((go<0?0:cosgf[go][mg])+(fo<0?0:costf[mf][fo])+((bi<0)?0:bre[bi][mb])+((hi<0)?0:bre[hi][mh]))*disc+999)/1000+max(fi,0)*2);
- }
- int max(double a,int b)
- {
- if (a<b) return int(a);
- return b;
- }
- int pool=8;
- const int HOUR=1;
- int main()
- {
- std::ios_base::sync_with_stdio(false);
- ifstream cin("progressive1.in");
- ofstream cout("progressive1.out");
- cosgf[1][1]=1;
- cosgf[0][1]=0;
- cosgf[1][2]=2;
- cosgf[0][2]=0;
- cosgf[1][3]=3;
- cosgf[0][3]=0;
- for (int i=2;i<1000;i+=2)
- {
- for (int j=1;j<=3;++j)
- {
- cosgf[i][j]=cosgf[i-1][j]+cosgf[i-1][j]-cosgf[i-2][j]+1;
- cosgf[i+1][j]=cosgf[i][j]+(cosgf[i][j]-cosgf[i-1][j])+2;
- //cout<<j<<' '<<i<<' '<<cosgf[i][j]<<endl<<i+1<<' '<<cosgf[i+1][j]<<endl;
- }
- }
- costf[5][1]=5;
- cosgf[1][5]=5;
- bre[1][10]=10;
- costf[12][1]=1;
- for (int i=2;i<1000;++i)
- {
- costf[5][i]=cosgf[i][5]=costf[5][i-1]*2-costf[5][i-2]+3;
- bre[i][10]=bre[i-1][10]*2-bre[i-2][10]+3;
- }
- for (int i=2;i<1000;i+=2)
- {
- costf[12][i]=costf[12][i-1]*2-costf[12][i-2];
- costf[12][i+1]=costf[12][i]*2-costf[12][i-1]+1;
- }
- costf[3][1]=3;
- for (int i=2;i<1000;++i) costf[3][i]=costf[3][i-1]+i+2;
- for (int i=1;i<1000;++i) costf[1][i]=costf[1][i-1]+i;
- costf[2][1]=2;
- for (int i=2;i<1000;++i) costf[2][i]=costf[2][i-1]+i+1;
- for (int i=1;i<1000;++i) costf[21][i]=cosgf[i][21]=costf[1][i]*2;
- for (int i=1;i<1000;++i) bre[i][31]=bre[i-1][31]+2*i+1,//cout<<bre[i][31]<<' ';
- //cout<<cosgf[55][21]<<' '<<costf[21][30]<<' '<<fig[3][3]<<' '<<bre[8][31]<<endl;
- //cout<<endl;
- for (int i=1;i<1000;++i) costf[11][i]=cosgf[i][1];
- for (int i=1;i<1000;++i) bre[i][51]=bre[i][31]+2*i;
- costf[14][1]=1;
- for (int i=2;i<1000;++i) costf[14][i]=costf[14][i-1]*2-costf[14][i-2]+3;
- bre[1][3]=3;
- bre[1][4]=4;
- bre[1][41]=4;
- bre[1][42]=4;
- bre[1][33]=3;
- bre[1][34]=3;
- for (int i=2;i<1000;++i) bre[i][42]=bre[i-1][42]*2-bre[i-2][42]+2;
- for (int i=2;i<1000;i+=2)
- {
- for (int j=3;j<=4;++j)
- {
- bre[i][j]=bre[i-1][j]+bre[i-1][j]-bre[i-2][j]+1;
- bre[i+1][j]=bre[i][j]+(bre[i][j]-bre[i-1][j])+2;
- }
- bre[i][41]=bre[i-1][41]+bre[i-1][41]-bre[i-2][41]+2;
- bre[i+1][41]=bre[i][41]+bre[i][41]-bre[i-1][41]+3;
- bre[i][33]=bre[i-1][33]+bre[i-1][33]-bre[i-2][33]+2;
- bre[i+1][33]=bre[i][33]+bre[i][33]-bre[i-1][33]+3;
- bre[i][34]=bre[i-1][34]*2-bre[i-2][34]+1;
- bre[i+1][34]=bre[i][34]*2-bre[i-1][34]+1;
- }
- cosgf[1][31]=3;
- for (int i=2;i<1000;++i) cosgf[i][31]=cosgf[i-1][31]*2-cosgf[i-2][31]+1;
- bre[1][43]=4;
- bre[2][43]=11;
- for (int i=2;i<1000;++i) bre[i][43]=bre[i-1][43]*2-bre[i-2][43]+3;
- for (int i=1;i<1000;++i) cosgf[i][11]=costf[1][i];
- bre[1][32]=3;
- for (int i=2;i<1000;++i) bre[i][32]=bre[i-1][32]*2-bre[i-2][32]+5;
- cin>>t;
- cout<<t<<en;
- for (int j=1;j<=59;++j)
- {
- //cout<<j<<' ';
- for (int i=1;i<10;++i) //cout<<cosgf[i][j]-cosgf[i-1][j]<<" \n"[i==9];
- }
- //cout<<endl;
- for (int j=1;j<=59;++j)
- {
- //cout<<j<<' ';
- for (int i=1;i<10;++i) //cout<<costf[j][i]-costf[j][i-1]<<" \n"[i==9];
- }
- //cout<<endl;
- for (int j=1;j<=59;++j)
- {
- //cout<<j<<' ';
- for (int i=1;i<10;++i) //cout<<bre[i][j]-bre[i-1][j]<<" \n"[i==9];
- }
- //cout<<en;
- for (int i=0;i<100;++i) //cout<<cosgf[i][1]<<' ';
- //cout<<endl<<cosgf[21][1]<<' '<<cosgf[20][1];
- /*GOLD:
- 1-1,2,4,5,7,8,10,...
- 2-2,3,5,6,8,9,11,...
- 3-3,4,6,7,9,10,12,...
- 5-5,8,11,14,17,20,23,...
- 11-1,2,3,4,5,6,7,...
- 21-2,4,6,8,10,12,14,...
- 31-3,4,5,6,7,8,9,...
- */
- /*FOOD:
- 1-1,2,3,4,5,6,...
- 2-2,3,4,5,6,7,...
- 3-3,4,5,6,7,8,...
- 5-5,8,11,14,17,20,...
- 11-1,2,4,5,7,8,...
- 21-2,4,6,8,10,12,...
- 12-1,1,2,2,3,3,4,4,...
- 14-1,4,7,10,13,16,...
- */
- /*BREEDING:
- 3-3,4,6,7,9,10,12,...
- 4-4,5,7,8,10,11,13,...
- 10-10,13,16,19,22,25,...
- 31-3,5,7,9,11,13,15,...
- 32-3,8,13,18,23,28,33,38,...
- 33-3,5,8,10,13,15,18,...
- 34-3,4,5,6,7,8,9,10,...
- 41-4,6,9,11,14,16,19,...
- 42-4,6,8,10,12,14,16,...
- 43-4,7,10,13,16,19,22,...
- 51-5,7,9,11,13,15,17,...
- */
- //cout<<fixed<<setprecision(6);
- int ko=0;
- while (t--)
- {
- bool x;
- cin>>gi>>fi>>fight>>bi>>hi>>ge>>meg>>mef>>mei>>meb>>meh>>x;
- //cout<<cosgf[gi][meg]<<endl;
- //cout<<(gi<0?0:cosgf[gi][meg])<<' '<<(fi<0?0:costf[mef][fi])<<' '<<(fight<0?0:fig[mei][fight])<<' '<<((bi<0)?0:bre[bi][meb])<<' '<<((hi<0)?0:bre[hi][meh])<<endl;
- //cout<<gi<<' '<<fi<<' '<<fight<<' '<<bi<<' '<<hi<<' '<<ge<<' '<<meg<<' '<<mef<<' '<<mei<<' '<<meb<<' '<<meh<<endl;
- //cout<<cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<' '<<ge<<' ';
- if (cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)==ge) disc=1;
- bool go=0;
- for (int i=1;i<=100;++i) if ((cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)*i+99)/100==ge) //cout<<i<<' ',disc=i*10,go=1;
- if (!go) for (int i=1;i<=100;++i) if ((cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)*(2*i+1)+199)/200==ge) //cout<<i<<".5"<<' ',disc=i*10+5,go=1;
- if (!go) for (int i=1;i<=1000;++i) if ((cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)*i+999)/1000==ge) //cout<<i/10<<"."<<i%10<<' ',disc=i,go=1;
- //cout<<disc<<endl;
- int gp=6,fp=4;
- int gt=(gi-gp*!x)*(pool*60/gp),ft=(fi-fp*!x)*(pool*60/fp);
- //cout<<gi<<' '<<fi<<' '<<gt<<' '<<ft<<' '<<cost(gi-1,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<endl;
- int prg=cost(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh);
- ////cout<<prg<<en;
- int mat=max(max(gt,ft),60*max(max((fight-!ko*!x)*2,(hi-1*!x)*pool),(bi-1*!x)*pool));
- //cout<<mat<<endl;
- int pgi=gi,pfi=fi,pfight=fight,phi=hi,pbi=bi;
- ////cout<<mat<<en;
- cout<<(mat+(HOUR*60-1))/(HOUR*60)+1<<en;
- if (x==0)
- {
- pgi-=gp;
- pfi-=fp;
- --pfight;
- --phi;
- --pbi;
- }
- cout<<"0 0 "<<0<<" "<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<en;
- for (int i=HOUR;i*60-HOUR*60<mat;i+=HOUR)
- {
- /*--pgi;
- cout<<min(i*60+80,mat)/1440<<' '<<(min(i*60+80,mat)/60)%24<<' '<<min(i*60+80,mat)%60<<" "<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<en;
- --pfi;
- --pfight;
- cout<<min(i*60+120,mat)/1440<<' '<<(min(i*60+120,mat)/60)%24<<' '<<min(i*60+120,mat)%60<<" "<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<en;
- --pgi;
- cout<<min(i*60+160,mat)/1440<<' '<<(min(i*60+160,mat)/60)%24<<' '<<min(i*60+160,mat)%60<<" "<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<en;
- --pgi;
- --pfi;
- --pfight;
- if (i%8==0)
- {
- --phi;
- --pbi;
- }
- cout<<min(i*60+240,mat)/1440<<' '<<(min(i*60+240,mat)/60)%24<<' '<<min(i*60+240,mat)%60<<" "<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<en;
- ////cout<<i<<' '<<pool<<' '<<pgi<<' '<<pfi<<' '<<pfight<<' '<<pbi<<' '<<phi<<en;*/
- pgi=gi-gp*!x-i*gp/pool;
- pfi=fi-fp*!x-i*fp/pool;
- pfight=fight-1-i/2;
- pbi=bi-!x-i/pool;
- phi=hi-!x-i/pool;
- cout<<i/24<<' '<<i%24<<' '<<0<<' '<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<endl;
- }
- /*if (fight)
- {
- gi-=gp;
- fi-=fp;
- if (ko==0) --fight;
- --hi;
- --bi;
- --gi;
- --fi;
- --fight;
- cout<<"0 0 120 "<<cost(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<en;
- if (ko!=0)
- {
- --fight;
- --fight;
- --gi;
- --gi;
- --gi;
- --fi;
- --fi;
- cout<<"0 0 360 "<<cost(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<en;
- }
- }*/
- ++ko;
- }
- //cout<<cost1(57,31,1,8,8,11,12,12,34,34)<<' '<<cost1(57,31,0,8,8,11,12,12,34,34)<<endl;
- system("progressiveCLEAN");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement