Advertisement
Dorijanko

Thonk1

Nov 29th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.35 KB | None | 0 0
  1. /*
  2. ID: dorijan1
  3. TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
  4. LANG: C++11
  5. */
  6. #include <bits/stdc++.h>
  7.  
  8. using namespace std;
  9.  
  10. const int MOD=1000000007;
  11. const char en='\n';
  12. typedef long long int ll;
  13.  
  14. int t;
  15. int gi,fi,bi,hi,fight,ge,meg,mef,mei,meb,meh;
  16. int disc;
  17. double gt,ft;
  18. int cosgf[1001][1001];
  19. int costf[1001][1001];
  20. int bre[1001][1001];
  21. int fig[][4]={{0,0,0,0},
  22. {0,0,0,0},
  23. {0,0,0,0},
  24. {0,3,10,21},
  25. {0,0,0,0},
  26. {0,5,16,33},
  27. {0,0,0,0},
  28. {0,0,0,0},
  29. {0,3,8,15},
  30. {0,0,0,0},
  31. {0,10,30,60},
  32. {0,0,0,0},
  33. {0,3,7,12},
  34. {0,3,12,27}};
  35.  
  36. int cost1(int go,int fo,int fi,int bi,int hi,int mg,int mf,int mi,int mb,int mh)
  37. {
  38. 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]);
  39. return el;
  40. }
  41.  
  42. int cost(int go,int fo,int fi,int bi,int hi,int mg,int mf,int mi,int mb,int mh)
  43. {
  44. 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,
  45. (((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);
  46. }
  47.  
  48. int max(double a,int b)
  49. {
  50. if (a<b) return int(a);
  51. return b;
  52. }
  53.  
  54. int pool=8;
  55. const int HOUR=1;
  56.  
  57. int main()
  58. {
  59. std::ios_base::sync_with_stdio(false);
  60. ifstream cin("progressive1.in");
  61. ofstream cout("progressive1.out");
  62. cosgf[1][1]=1;
  63. cosgf[0][1]=0;
  64. cosgf[1][2]=2;
  65. cosgf[0][2]=0;
  66. cosgf[1][3]=3;
  67. cosgf[0][3]=0;
  68. for (int i=2;i<1000;i+=2)
  69. {
  70. for (int j=1;j<=3;++j)
  71. {
  72. cosgf[i][j]=cosgf[i-1][j]+cosgf[i-1][j]-cosgf[i-2][j]+1;
  73. cosgf[i+1][j]=cosgf[i][j]+(cosgf[i][j]-cosgf[i-1][j])+2;
  74. //cout<<j<<' '<<i<<' '<<cosgf[i][j]<<endl<<i+1<<' '<<cosgf[i+1][j]<<endl;
  75. }
  76. }
  77. costf[5][1]=5;
  78. cosgf[1][5]=5;
  79. bre[1][10]=10;
  80. costf[12][1]=1;
  81. for (int i=2;i<1000;++i)
  82. {
  83. costf[5][i]=cosgf[i][5]=costf[5][i-1]*2-costf[5][i-2]+3;
  84. bre[i][10]=bre[i-1][10]*2-bre[i-2][10]+3;
  85. }
  86. for (int i=2;i<1000;i+=2)
  87. {
  88. costf[12][i]=costf[12][i-1]*2-costf[12][i-2];
  89. costf[12][i+1]=costf[12][i]*2-costf[12][i-1]+1;
  90. }
  91. costf[3][1]=3;
  92. for (int i=2;i<1000;++i) costf[3][i]=costf[3][i-1]+i+2;
  93. for (int i=1;i<1000;++i) costf[1][i]=costf[1][i-1]+i;
  94. costf[2][1]=2;
  95. for (int i=2;i<1000;++i) costf[2][i]=costf[2][i-1]+i+1;
  96. for (int i=1;i<1000;++i) costf[21][i]=cosgf[i][21]=costf[1][i]*2;
  97. for (int i=1;i<1000;++i) bre[i][31]=bre[i-1][31]+2*i+1,//cout<<bre[i][31]<<' ';
  98. //cout<<cosgf[55][21]<<' '<<costf[21][30]<<' '<<fig[3][3]<<' '<<bre[8][31]<<endl;
  99. //cout<<endl;
  100. for (int i=1;i<1000;++i) costf[11][i]=cosgf[i][1];
  101. for (int i=1;i<1000;++i) bre[i][51]=bre[i][31]+2*i;
  102. costf[14][1]=1;
  103. for (int i=2;i<1000;++i) costf[14][i]=costf[14][i-1]*2-costf[14][i-2]+3;
  104. bre[1][3]=3;
  105. bre[1][4]=4;
  106. bre[1][41]=4;
  107. bre[1][42]=4;
  108. bre[1][33]=3;
  109. bre[1][34]=3;
  110. for (int i=2;i<1000;++i) bre[i][42]=bre[i-1][42]*2-bre[i-2][42]+2;
  111. for (int i=2;i<1000;i+=2)
  112. {
  113. for (int j=3;j<=4;++j)
  114. {
  115. bre[i][j]=bre[i-1][j]+bre[i-1][j]-bre[i-2][j]+1;
  116. bre[i+1][j]=bre[i][j]+(bre[i][j]-bre[i-1][j])+2;
  117. }
  118. bre[i][41]=bre[i-1][41]+bre[i-1][41]-bre[i-2][41]+2;
  119. bre[i+1][41]=bre[i][41]+bre[i][41]-bre[i-1][41]+3;
  120. bre[i][33]=bre[i-1][33]+bre[i-1][33]-bre[i-2][33]+2;
  121. bre[i+1][33]=bre[i][33]+bre[i][33]-bre[i-1][33]+3;
  122. bre[i][34]=bre[i-1][34]*2-bre[i-2][34]+1;
  123. bre[i+1][34]=bre[i][34]*2-bre[i-1][34]+1;
  124. }
  125. cosgf[1][31]=3;
  126. for (int i=2;i<1000;++i) cosgf[i][31]=cosgf[i-1][31]*2-cosgf[i-2][31]+1;
  127. bre[1][43]=4;
  128. bre[2][43]=11;
  129. for (int i=2;i<1000;++i) bre[i][43]=bre[i-1][43]*2-bre[i-2][43]+3;
  130. for (int i=1;i<1000;++i) cosgf[i][11]=costf[1][i];
  131. bre[1][32]=3;
  132. for (int i=2;i<1000;++i) bre[i][32]=bre[i-1][32]*2-bre[i-2][32]+5;
  133. cin>>t;
  134. cout<<t<<en;
  135. for (int j=1;j<=59;++j)
  136. {
  137. //cout<<j<<' ';
  138. for (int i=1;i<10;++i) //cout<<cosgf[i][j]-cosgf[i-1][j]<<" \n"[i==9];
  139. }
  140. //cout<<endl;
  141. for (int j=1;j<=59;++j)
  142. {
  143. //cout<<j<<' ';
  144. for (int i=1;i<10;++i) //cout<<costf[j][i]-costf[j][i-1]<<" \n"[i==9];
  145. }
  146. //cout<<endl;
  147. for (int j=1;j<=59;++j)
  148. {
  149. //cout<<j<<' ';
  150. for (int i=1;i<10;++i) //cout<<bre[i][j]-bre[i-1][j]<<" \n"[i==9];
  151. }
  152. //cout<<en;
  153. for (int i=0;i<100;++i) //cout<<cosgf[i][1]<<' ';
  154. //cout<<endl<<cosgf[21][1]<<' '<<cosgf[20][1];
  155. /*GOLD:
  156. 1-1,2,4,5,7,8,10,...
  157. 2-2,3,5,6,8,9,11,...
  158. 3-3,4,6,7,9,10,12,...
  159. 5-5,8,11,14,17,20,23,...
  160. 11-1,2,3,4,5,6,7,...
  161. 21-2,4,6,8,10,12,14,...
  162. 31-3,4,5,6,7,8,9,...
  163. */
  164.  
  165. /*FOOD:
  166. 1-1,2,3,4,5,6,...
  167. 2-2,3,4,5,6,7,...
  168. 3-3,4,5,6,7,8,...
  169. 5-5,8,11,14,17,20,...
  170. 11-1,2,4,5,7,8,...
  171. 21-2,4,6,8,10,12,...
  172. 12-1,1,2,2,3,3,4,4,...
  173. 14-1,4,7,10,13,16,...
  174. */
  175.  
  176. /*BREEDING:
  177. 3-3,4,6,7,9,10,12,...
  178. 4-4,5,7,8,10,11,13,...
  179. 10-10,13,16,19,22,25,...
  180. 31-3,5,7,9,11,13,15,...
  181. 32-3,8,13,18,23,28,33,38,...
  182. 33-3,5,8,10,13,15,18,...
  183. 34-3,4,5,6,7,8,9,10,...
  184. 41-4,6,9,11,14,16,19,...
  185. 42-4,6,8,10,12,14,16,...
  186. 43-4,7,10,13,16,19,22,...
  187. 51-5,7,9,11,13,15,17,...
  188. */
  189. //cout<<fixed<<setprecision(6);
  190. int ko=0;
  191. while (t--)
  192. {
  193. bool x;
  194. cin>>gi>>fi>>fight>>bi>>hi>>ge>>meg>>mef>>mei>>meb>>meh>>x;
  195. //cout<<cosgf[gi][meg]<<endl;
  196. //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;
  197. //cout<<gi<<' '<<fi<<' '<<fight<<' '<<bi<<' '<<hi<<' '<<ge<<' '<<meg<<' '<<mef<<' '<<mei<<' '<<meb<<' '<<meh<<endl;
  198. //cout<<cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<' '<<ge<<' ';
  199. if (cost1(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)==ge) disc=1;
  200. bool go=0;
  201. 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;
  202. 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;
  203. 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;
  204. //cout<<disc<<endl;
  205. int gp=6,fp=4;
  206. int gt=(gi-gp*!x)*(pool*60/gp),ft=(fi-fp*!x)*(pool*60/fp);
  207. //cout<<gi<<' '<<fi<<' '<<gt<<' '<<ft<<' '<<cost(gi-1,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<endl;
  208. int prg=cost(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh);
  209. ////cout<<prg<<en;
  210. int mat=max(max(gt,ft),60*max(max((fight-!ko*!x)*2,(hi-1*!x)*pool),(bi-1*!x)*pool));
  211. //cout<<mat<<endl;
  212. int pgi=gi,pfi=fi,pfight=fight,phi=hi,pbi=bi;
  213. ////cout<<mat<<en;
  214. cout<<(mat+(HOUR*60-1))/(HOUR*60)+1<<en;
  215. if (x==0)
  216. {
  217. pgi-=gp;
  218. pfi-=fp;
  219. --pfight;
  220. --phi;
  221. --pbi;
  222. }
  223. cout<<"0 0 "<<0<<" "<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<en;
  224. for (int i=HOUR;i*60-HOUR*60<mat;i+=HOUR)
  225. {
  226. /*--pgi;
  227. 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;
  228. --pfi;
  229. --pfight;
  230. 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;
  231. --pgi;
  232. 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;
  233. --pgi;
  234. --pfi;
  235. --pfight;
  236. if (i%8==0)
  237. {
  238. --phi;
  239. --pbi;
  240. }
  241. 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;
  242. ////cout<<i<<' '<<pool<<' '<<pgi<<' '<<pfi<<' '<<pfight<<' '<<pbi<<' '<<phi<<en;*/
  243. pgi=gi-gp*!x-i*gp/pool;
  244. pfi=fi-fp*!x-i*fp/pool;
  245. pfight=fight-1-i/2;
  246. pbi=bi-!x-i/pool;
  247. phi=hi-!x-i/pool;
  248. cout<<i/24<<' '<<i%24<<' '<<0<<' '<<cost(pgi,pfi,pfight,pbi,phi,meg,mef,mei,meb,meh)<<endl;
  249. }
  250. /*if (fight)
  251. {
  252. gi-=gp;
  253. fi-=fp;
  254. if (ko==0) --fight;
  255. --hi;
  256. --bi;
  257. --gi;
  258. --fi;
  259. --fight;
  260. cout<<"0 0 120 "<<cost(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<en;
  261. if (ko!=0)
  262. {
  263. --fight;
  264. --fight;
  265. --gi;
  266. --gi;
  267. --gi;
  268. --fi;
  269. --fi;
  270. cout<<"0 0 360 "<<cost(gi,fi,fight,bi,hi,meg,mef,mei,meb,meh)<<en;
  271. }
  272. }*/
  273. ++ko;
  274. }
  275. //cout<<cost1(57,31,1,8,8,11,12,12,34,34)<<' '<<cost1(57,31,0,8,8,11,12,12,34,34)<<endl;
  276. system("progressiveCLEAN");
  277. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement