比赛 东方版NOIP模拟赛 评测结果 AAWAAAAAAA
题目名称 Yukari 最终得分 90
用户昵称 不错封ID几十块 运行时间 0.270 s
代码语言 C++ 内存使用 2.60 MiB
提交时间 2015-10-28 21:59:15
显示代码纯文本
  1. #include<algorithm>
  2. #include<iostream>
  3. #include<cstdio>
  4. #include<cmath>
  5. #define maxn 300010
  6. #define inf 0x7fffffff
  7. using namespace std;
  8. struct td
  9. {
  10. int t;
  11. bool r;
  12. bool operator<(const td& a)const
  13. {
  14. return (t<a.t);
  15. }
  16. }mt[maxn];
  17. int n;
  18. int e;
  19. int xl,xr,yl,yr;
  20. int main()
  21. {
  22. freopen("camera.in","r",stdin);
  23. freopen("camera.out","w",stdout);
  24. int i;
  25. int tt;
  26. int mxt;
  27. int ans;
  28. int xopt,xedt;
  29. int yopt,yedt;
  30. int xi,yi,ui,vi;
  31. e=0;
  32. scanf("%d",&n);
  33. scanf("%d%d%d%d",&xl,&yl,&xr,&yr);
  34. for(i=1;i<=n;i++){
  35. scanf("%d%d%d%d",&xi,&yi,&ui,&vi);
  36. xopt=-1;
  37. xedt=-1;
  38. yopt=-1;
  39. yedt=-1;
  40. if(ui<0){
  41. if(xi>xr){
  42. xopt=((xr-xi)/ui)+((xr-xi)%ui!=0);
  43. xedt=((xl-xi)/ui);
  44. }
  45. else{
  46. if(xi>=xl){
  47. xopt=0;
  48. xedt=(xl-xi)/ui;
  49. }
  50. }
  51. }
  52. if(ui>0){
  53. if(xi<xl){
  54. xopt=((xl-xi)/ui)+((xl-xi)%ui!=0);
  55. xedt=((xr-xi)/ui);
  56. }
  57. else{
  58. if(xi<=xr){
  59. xopt=0;
  60. xedt=(xr-xi)/ui;
  61. }
  62. }
  63. }
  64. if(vi<0){
  65. if(yi>yr){
  66. yopt=((yr-yi)/vi)+((yr-yi)%vi!=0);
  67. yedt=((yl-yi)/vi);
  68. }
  69. else{
  70. if(yi>=yl){
  71. yopt=0;
  72. yedt=(yl-yi)/vi;
  73. }
  74. }
  75. }
  76. if(vi>0){
  77. if(yi<yl){
  78. yopt=((yl-yi)/vi)+((yl-yi)%vi!=0);
  79. yedt=((yr-yi)/vi);
  80. }
  81. else{
  82. if(yi<=yr){
  83. yopt=0;
  84. yedt=(yr-yi)/vi;
  85. }
  86. }
  87. }
  88. if(ui==0){
  89. if(xl<=xi && xi<=xr){
  90. xopt=0;
  91. xedt=inf;
  92. }
  93. }
  94. if(vi==0){
  95. if(yl<=yi && yi<=yr){
  96. yopt=0;
  97. yedt=inf;
  98. }
  99. }
  100. if(xopt!=-1 && yedt!=-1){
  101. tt=max(xopt,yopt);
  102. xi+=tt*ui;
  103. yi+=tt*vi;
  104. if(xl<=xi && xi<=xr && yl<=yi && yi<=yr){
  105. e++;
  106. mt[e].t=tt;
  107. mt[e].r=true;
  108. e++;
  109. mt[e].t=min(xedt,yedt);
  110. mt[e].r=false;
  111. }
  112. }
  113. }
  114. sort(&mt[1],&mt[e+1]);
  115. tt=0;
  116. mxt=-inf;
  117. for(i=1;i<=e;i++){
  118. tt+=(mt[i].r*2-1);
  119. if(tt>mxt){
  120. ans=mt[i].t;
  121. mxt=tt;
  122. }
  123. }
  124. printf("%d\n",ans);
  125. return 0;
  126. }