fork(1) download
  1. uses math;
  2. type ttype=record
  3. x,y,z:longint;
  4. end;
  5. var n,i,u,v,j,k,t,x,y,z,m,q:longint;
  6. sum,kq,s:int64;
  7. fi,fo:text;
  8. b,c:array[1..65]of ttype;
  9. xe,hau,tuong,ma:array[0..65,0..65]of boolean;
  10. a:array[0..9,0..9]of longint;
  11. begin
  12. assign(fi,'bonus13.inp');reset(fi);
  13. assign(fo,'bonus13.out');rewrite(fo);
  14. readln(fi,n);
  15. sum:=0;m:=0;
  16. for i:=1to n do
  17. begin
  18. readln(fi,x,y,z);
  19. a[x,y]:=z;
  20. b[i].x:=x;
  21. b[i].y:=y;
  22. inc(sum,z);
  23. end;
  24. close(fi);
  25. for i:=1to 8 do
  26. for j:=1to 8 do
  27. if a[i,j]=0 then
  28. begin
  29. inc(m);
  30. c[m].x:=i;
  31. c[m].y:=j;
  32. end;
  33. for i:=1to n do
  34. for j:=1to m do
  35. begin
  36. u:=b[i].x;
  37. v:=b[i].y;
  38. x:=c[j].x;
  39. y:=c[j].y;
  40. if (u=x)or(v=y)then xe[i,j]:=true;
  41. if ((u-v=x-y)or(u+v=x+y))then tuong[i,j]:=true;
  42. if (xe[i,j]or tuong[i,j])then hau[i,j]:=true;
  43. if ((abs(y-v)=1)and(abs(x-u)=2))or((abs(x-u)=2)and(abs(y-v)=1))then
  44. ma[i,j]:=true;
  45. end;
  46. for i:=1to m do
  47. for j:=1to m do
  48. for k:=1to m do
  49. for t:=1to m do
  50. begin
  51. if (i=j)or(i=k)or(i=t)or(j=k)or(j=t)or(k=t)then continue;
  52. s:=0;
  53. for q:=1to n do
  54. if (hau[q,i])or(xe[q,j])or(tuong[q,k])or(ma[q,t])then
  55. inc(s,a[b[q].x,b[q].y]);
  56. kq:=max(kq,s);
  57. if kq=sum then
  58. begin
  59. write(fo,kq);
  60. close(fo);
  61. exit;
  62. end;
  63. end;
  64. write(fo,kq);
  65. close(fo);
  66. end.
  67.  
  68.  
Runtime error #stdin #stdout 0s 500KB
stdin
Standard input is empty
stdout
An unhandled exception occurred at $0804812C :
EInOutError : File not found
  $0804812C