【codeforces 793C】Mice problem
【题目链接】: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的更多相关文章
- 【codeforces 527D】Clique Problem
[题目链接]:http://codeforces.com/contest/527/problem/D [题意] 一维线段上有n个点 每个点有坐标和权值两个域分别为xi,wi; 任意一对点(i,j) 如 ...
- 【codeforces 807D】Dynamic Problem Scoring
[题目链接]:http://codeforces.com/contest/807/problem/D [题意] 给出n个人的比赛信息; 5道题 每道题,或是没被解决->用-1表示; 或者给出解题 ...
- 【26.09%】【codeforces 579C】A Problem about Polyline
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 749A】Bachgold Problem
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【Codeforces 1096D】Easy Problem
[链接] 我是链接,点我呀:) [题意] 让你将一个字符串删掉一些字符. 使得字符串中不包含子序列"hard" 删掉每个字符的代价已知为ai 让你求出代价最小的方法. [题解] 设 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 798C】Mike and gcd problem
[题目链接]:http://codeforces.com/contest/798/problem/C [题意] 给你n个数字; 要求你进行若干次操作; 每次操作对第i和第i+1个位置的数字进行; 将 ...
- 【Codeforces 105D】 Bag of mice
[题目链接] http://codeforces.com/contest/148/problem/D [算法] 概率DP f[w][b]表示还剩w只白老鼠,b只黑老鼠,公主胜利的概率,那么 : 1. ...
- 【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 ...
随机推荐
- ios添加麦克风访问权限
不然程序崩溃: This app has crashed because it attempted to access privacy-sensitive data without a usage d ...
- 修复nexus4由于使用完美刷机或者刷机精灵导致的底层文件受损
前一段nexus4升级android 4.4.4的时候突然发现无法使用线刷刷入官方镜像了.当时就感觉很奇怪,但是不知道怎么搞得刷进去了,但是第一次开机的时候总是卡在联网之后的验证(我当时以为是网络不好 ...
- bin/sh^M:损坏的解释器: 没有那个文件或目录
脚本文件保存时使用了DOS格式,用DOS2UNIX转为UNIX格式,也可以用vim打开,用:set ff=unix转换.不要在 Windows下编辑脚本文件,否则经常会遇到这种问题. 代码:sed - ...
- [Apple开发者帐户帮助]六、配置应用服务(1.1)Apple Pay:配置Apple Pay(iOS,watchOS)
Apple Pay允许用户在您的应用中购买商品和服务.要将Apple Pay 权利添加到您的App ID,请先创建商家标识符,然后启用Apple Pay并创建付款处理证书. 或者,您可以使用Xcode ...
- MYSQL 数据库命令行终端操作笔记
1.数据库登录: 1.登录本地的MYSQL数据库:mysql -u root -p 2.连接远程主机上的MYSQL数据库:mysql -h 192.168.191.2 -u root -p 123 ...
- python 13:数字列表统计方法(min(list)、max(list)、sum(list))
numbers = list(range(1,11)) print(numbers) print(min(numbers)) #获得列表最小值 print(max(numbers)) #获得列表最大值 ...
- android ui篇
android ui篇主要做两件事情. 第一件事情就是能够自己去定义基本的简单的界面. 第二件事情就是能够使用开源library去构造一些复杂的界面. 第一件事情就需要对于布局等方面知识有着基本的掌握 ...
- 2-SAT的小总结(POJ 3683 POJ 3207)
记住几个最重要的公式: xANDy=0<=>(x=>y′)AND(y=>x′) xANDy=1<=>(x′=>x)AND(y′=>y) xORy=0&l ...
- 跳出双重for循环的案例__________跳出当前循环(continue out)
package com.etc.operator; public class demo { public static void main(String[] args) { // break out; ...
- vs2008 启动IE浏览器 出现DW20.exe占用大量cpu 服务器iis 异常调试
DW20.exe占用大量cpu 服务器iis运行出现异常想查一下故障原因,发现有好几个DW20.exe进程,每个占用20%左右的cpu,在任务管理器中将其终止后,它又自动运行起来了 查了一下DW20. ...