【题目链接】: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



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,0,-1,0,-1,-1,1,1};
const int dy[9] = {0,0,-1,0,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;
const double eps = 3e-15; int n;
int x1,y1,x2,y2,x0,y0,vx,vy;
double zuo = 0,you = 1e9; void o()
{
cout << -1 << endl;
exit(0);
} void up_data(int x,int vx,int l,int r)
{
if (vx==0)
{
if (l < x && x < r)
return;
else
o();
}
if (vx<0)
{
x = -x,vx = -vx;
l=-l,r = -r;
swap(l,r);
}
if (x>=r) o();
you = min(you,(r-x)/double(vx));
if (x<=l) zuo = max(zuo,(l-x)/double(vx));
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
ios::sync_with_stdio(false),cin.tie(0);//scanf,puts,printf not use
cin >> n;
cin >> x1 >> y1 >> x2 >> y2;
rep1(i,1,n)
{
cin >> x0 >> y0 >> vx >> vy;
up_data(x0,vx,x1,x2);
up_data(y0,vy,y1,y2);
}
if (you>=zuo*(1+eps))
cout << fixed << setprecision(12) << zuo << endl;
else
cout << -1 << endl;
return 0;
}

【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. luogu2157 [SDOI2009]学校食堂 局部状压

    题目大意 小F 的学校在城市的一个偏僻角落,所有学生都只好在学校吃饭.学校有一个食堂,虽然简陋,但食堂大厨总能做出让同学们满意的菜肴.当然,不同的人口味也不一定相同,但每个人的口味都可以用一个非负整数 ...

  2. B1295 [SCOI2009]最长距离 最短路

    就是一道最短路的裸题,直接跑spfa就行了.(spfa死了) 最后在答案处判断是否障碍物太多,然后就直接找最大值就行. (数据特别水,我错误算法60) 题干: Description windy有一块 ...

  3. vs2010永久删除项目的相关操作

    1.选中要删除的项目,在解决方案资源管理器中,直接左键点击一下即可.. 2.点击键盘的删除键“DElect”. 3.然后找到工程的目录后,删除项目.即可永久性删除不在需要的程序或者是项目.

  4. (Go)07.Go语言中strings和strconv包示例代码详解02

    1.strings使用 统计字符串出现次数 strings.Count(s string, substr string) int Count 用于计算字符串 substr 在字符串 s 中出现的非重叠 ...

  5. HDU3085 Nightmare Ⅱ

    题目: Last night, little erriyue had a horrible nightmare. He dreamed that he and his girl friend were ...

  6. Java多线程技术-Volatile关键字解析

    分析volatile关键字可以从这三个方面分析,什么是程序的原子性,什么是程序的可见性,什么是程序的有序性 什么是程序的原子性 以下语句那些是原子操作? public class ThreadCoun ...

  7. python 6:list.append(新元素)与list.insert(索引,新元素)(在列表末尾追加新元素、在索引处添加新元素)

    bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) bicycles.append("ho ...

  8. "etc/profile" E212: Can't open file for writing

    今天安装Java环境,出现如下错误: "etc/profile" E212: Can't open file for writing 这是安装到本地JDK路径不正确导致.怎么办呢? ...

  9. Asp.net MVC4 Step By Step(4)-使用Ajax

    Ajax技术就是利用Javascript和XML技术实现这样的效果, 可以向Web服务器发送异步请求, 返回更新部分页面的数据, 而不需要全部更新整个页面. Ajax请求两种类型的内容, 一种是服务端 ...

  10. 【sqli-labs】 less6 GET - Double Injection - Double Quotes - String (双注入GET双引号字符型注入)

    同less5 单引号改成双引号就行 http://localhost/sqli/Less-6/?id=a" union select 1,count(*),concat((select ta ...