【题目链接】:http://codeforces.com/contest/793/problem/C

【题意】



给你每个点x轴移动速度,y轴移动速度;

问你有没有某个时刻,所有的点都“严格”在所给的矩形内

【题解】



把二维的问题转化成一维的问题;

那样问题就转换成

x1..x2是目标的线段(一维的)

然后有若干个xi

问你从xi变化到到x1..x2这个区间最短和最长时间(分别对应第一次进入这个区间和出这个区间的时间);

yi同理;

然后求时间的交集就可以了;

对于都刚好在边框上的情况;

用精度来填补

精度调越小越好!

vx<0的情况

可以把它都转成负数;

然后对称着做;

注意vx=0的特判;

以及vx的正负和所需要的方向不同的判断;

数据往里面传的时候,先传Int的会快很多



【Number Of WA】



6



【完整代码】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,m,rt<<1
  4. #define rson m+1,r,rt<<1|1
  5. #define LL long long
  6. #define rep1(i,a,b) for (int i = a;i <= b;i++)
  7. #define rep2(i,a,b) for (int i = a;i >= b;i--)
  8. #define mp make_pair
  9. #define pb push_back
  10. #define fi first
  11. #define se second
  12. #define ms(x,y) memset(x,y,sizeof x)
  13. typedef pair<int,int> pii;
  14. typedef pair<LL,LL> pll;
  15. const int dx[9] = {0,1,0,-1,0,-1,-1,1,1};
  16. const int dy[9] = {0,0,-1,0,1,-1,1,-1,1};
  17. const double pi = acos(-1.0);
  18. const int N = 1e5+100;
  19. const double eps = 3e-15;
  20. int n;
  21. int x1,y1,x2,y2,x0,y0,vx,vy;
  22. double zuo = 0,you = 1e9;
  23. void o()
  24. {
  25. cout << -1 << endl;
  26. exit(0);
  27. }
  28. void up_data(int x,int vx,int l,int r)
  29. {
  30. if (vx==0)
  31. {
  32. if (l < x && x < r)
  33. return;
  34. else
  35. o();
  36. }
  37. if (vx<0)
  38. {
  39. x = -x,vx = -vx;
  40. l=-l,r = -r;
  41. swap(l,r);
  42. }
  43. if (x>=r) o();
  44. you = min(you,(r-x)/double(vx));
  45. if (x<=l) zuo = max(zuo,(l-x)/double(vx));
  46. }
  47. int main()
  48. {
  49. //freopen("F:\\rush.txt","r",stdin);
  50. ios::sync_with_stdio(false),cin.tie(0);//scanf,puts,printf not use
  51. cin >> n;
  52. cin >> x1 >> y1 >> x2 >> y2;
  53. rep1(i,1,n)
  54. {
  55. cin >> x0 >> y0 >> vx >> vy;
  56. up_data(x0,vx,x1,x2);
  57. up_data(y0,vy,y1,y2);
  58. }
  59. if (you>=zuo*(1+eps))
  60. cout << fixed << setprecision(12) << zuo << endl;
  61. else
  62. cout << -1 << endl;
  63. return 0;
  64. }

【codeforces 793C】Mice problem的更多相关文章

  1. 【codeforces 527D】Clique Problem

    [题目链接]:http://codeforces.com/contest/527/problem/D [题意] 一维线段上有n个点 每个点有坐标和权值两个域分别为xi,wi; 任意一对点(i,j) 如 ...

  2. 【codeforces 807D】Dynamic Problem Scoring

    [题目链接]:http://codeforces.com/contest/807/problem/D [题意] 给出n个人的比赛信息; 5道题 每道题,或是没被解决->用-1表示; 或者给出解题 ...

  3. 【26.09%】【codeforces 579C】A Problem about Polyline

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【codeforces 749A】Bachgold Problem

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【Codeforces 1096D】Easy Problem

    [链接] 我是链接,点我呀:) [题意] 让你将一个字符串删掉一些字符. 使得字符串中不包含子序列"hard" 删掉每个字符的代价已知为ai 让你求出代价最小的方法. [题解] 设 ...

  6. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  7. 【codeforces 798C】Mike and gcd problem

    [题目链接]:http://codeforces.com/contest/798/problem/C [题意] 给你n个数字; 要求你进行若干次操作; 每次操作对第i和第i+1个位置的数字进行; 将 ...

  8. 【Codeforces 105D】 Bag of mice

    [题目链接] http://codeforces.com/contest/148/problem/D [算法] 概率DP f[w][b]表示还剩w只白老鼠,b只黑老鼠,公主胜利的概率,那么 : 1. ...

  9. 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. [odroid-pc] ubuntu12.04 android4.0移植到odroid-pc过程

    參考:http://blog.csdn.net/sunnybeike/article/details/8098349 odroid  prebuilt版 img下载地址:tag=ODROID-PC&q ...

  2. sublime text3编译C/C++系统提示丢失zlib1.dll解决的方法

    用g++ 编译C/C++程序时 出现例如以下系统提示: 解决的方法例如以下: 1.下载zlib1.dll: http://www.pc6.com/softview/SoftView_81060.htm ...

  3. 一段程序的人生 第10章: server

    从第0章開始看 第拾章 server     一切基本安顿下来,我開始认真的检阅一下我所栖身的文件夹.来到了外面的大世界,果然不一样.越是细致查看越是认为这里真是一个再好只是的地方. 这个文件夹里面有 ...

  4. ubuntu如何完全卸载和安装 Java及android环境?【转】

    本文转载自:https://my.oschina.net/lxrm/blog/110638 最近,迷上了java,一时间什么环境变量/虚拟机都猛然袭来,有点不适.环境配置在前,这所自然.平时搞PHP都 ...

  5. bzoj4197 [Noi2015]寿司晚宴——状压DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4197 首先,两个人选的数都互质可以看作是一个人选了一个数,就相当于选了一个质因数集合,另一个 ...

  6. Django day01 web应用程序 , http协议

    一:web应用程序1.什么是web应用程序 是一种可以通过web访问的应用程序,最大的好处就是, 只要有浏览器,用户就能很容易访问到应用程序 2. web应用程序的优缺点 缺点: 应用程序强调了浏览器 ...

  7. WebService开发-Hessian

    Hessian 开发Web Service 一.关于Hessian Hessian是一个轻量级的remoting on http工具,使用简单的方法提供了RMI的功能. 相比WebService,He ...

  8. 遍历WPF DataGrid单元格

    using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Media; ...

  9. Bootstrap中container与container-fluid的区别

    /*0-768px以上宽度container为100%*/ .container { padding-right: 15px; padding-left: 15px; margin-right: au ...

  10. matlab中 注意事项--字符串

    Matlab中的字符串操作 原文链接:http://hi.baidu.com/dreamflyman/item/bd6d8224430003c9a5275a9f (1).字符串是以ASCII码形式存储 ...