UVa 11627 - Slalom 二分. oj错误题目 难度: 0
题目
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2674
题意
有严格下降的n条线段,长度都为w,第i条线段起点xi,终点xi + w,高度yi,现在有s种垂直恒定速度可以选择,水平速度不能超过vh,问要经过每条线段,垂直恒定速度最大可以选择什么
思路
明显,二分枚举速度speed
第一条线段因为是起点所以肯定都能到达
对于第i条线段,从第i-1条线段出发落到i条线段相同高度所用时间为t = (yi - y_{i - 1}) / speed,设能到达的区域为[xlefttruei, xrighttruei],能到达的区域为[xlefttrue_{i-1}- vh * t, xrighttrue_{i-1} + vh * t]与自身线段[xi, xi + w]的交集,如果不存在这个交集,就代表落不到这个线段上。
感想:
现在uva无法通过,包括他人题解注明已通过的也不行
代码
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#define LOCAL_DEBUG
using namespace std;
const int MAXN = 1e5 + ;
const int MAXS = 1e6 + ;
long long xleft[MAXN];
long long y[MAXN];
long long w, vh;
int n, s;
long long xlefttrue[MAXN], xrighttrue[MAXN];
int speeds[MAXS];
bool check(int speed) {
xlefttrue[] = xleft[] * speed;
xrighttrue[] = (xleft[] + w) * speed;
for (int i = ; i < n; i++) {
long long t = (y[i] - y[i - ]);
xlefttrue[i] = max(xleft[i] * speed, xlefttrue[i - ] - t * vh);
xrighttrue[i] = min((xleft[i] + w) * speed, xrighttrue[i - ] + t * vh);
if (xlefttrue[i] > xrighttrue[i])return false;
}
return true;
} int main() {
#ifdef LOCAL_DEBUG
freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\input.txt", "r", stdin);
//freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\output.txt", "w", stdout);
#endif // LOCAL_DEBUG
int T;
cin >> T;
for (int ti = ;ti <= T; ti++) {
cin >> w >> vh >> n;
for (int i = ; i < n; i++) {
cin >> xleft[i] >> y[i];
}
cin >> s;
for (int i = ; i < s; i++) {
cin >> speeds[i];
}
sort(speeds, speeds + s);
int lind = , rind = s;
if (!check(speeds[lind]))cout << "IMPOSSIBLE" <<endl;
else {
while (lind < rind) {
int mid = (lind + rind) >> ;
if (mid == lind)break;
if (check(speeds[mid])) {
lind = mid;
}
else {
rind = mid;
}
}
cout << speeds[lind] << endl;
}
} return ;
}
UVa 11627 - Slalom 二分. oj错误题目 难度: 0的更多相关文章
- HDU 3076 ssworld VS DDD 概率dp,无穷级数,oj错误题目 难度:2
http://acm.hdu.edu.cn/showproblem.php?pid=3076 不可思议的题目,总之血量越少胜率越高,所以读取时把两人的血量交换一下 明显每一轮的胜率和负率都是固定的,所 ...
- UVA 11627 Slalom(二分)
二分,判断的时候,一个点一个点的考虑肯定是不行啦,考虑的单位是一个区间, 每次左端点尽量向左边移动,右端点尽量向右,得到下次可以达到的范围,检查一下和下一个区间有没有交集. #include<b ...
- ZOJ 3521 Fairy Wars oj错误题目,计算几何,尺取法,排序二叉树,并查集 难度:2
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3521 ATTENTION:如果用long long 减小误差,这道题只能用 ...
- UVa 11636 - Hello World! 二分,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11134 - Fabled Rooks 优先队列,贪心 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 10340 - All in All 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 3602 - DNA Consensus String 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- UVa LA 3213 - Ancient Cipher 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- OJ提交题目中的语言选项里G++与C++的区别
一.OJ提交题目中的语言选项里G++与C++的区别 http://www.th7.cn/Program/cp/201405/199001.shtml 首先更正一个概念,C++是一门计算机编程语言,G+ ...
随机推荐
- Java第二次考试
代码 package sizeyunsuan; import java.io.FileNotFoundException; import java.io.PrintStream; import jav ...
- Cisco Packet Tracer
---恢复内容开始--- 1.简单局域网组建 交换机:2960 s1 终端设备:generic pc 配置 pc1 单击>>Descktop>>IP configur ...
- IIS下载无后缀文件的设置
HTTP 错误 404.3 - Not Found由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. 解决方法:MIME类型加 . ...
- Delphi文件目录操作(转载)
Delphi判断文件夹(目录)是否存在,不存在就创建一个,可以一次创建多级目录 procedure TForm1.Button1Click(Sender: TObject);begin if not ...
- configparser配置文件处理
创建一个configparser格式的文档: import configparser config = configparser.ConfigParser()config["DEFAULT& ...
- JavaScript 初知
JavaScript 初知 1.JavaScript 独立的语言2.浏览器就是JavaScript的语言解释器3.JavaScript 代码存在于HTML中4.单行注释用“//”.多行注释 /* */ ...
- Python while 循环
while循环的使用 count = 0 while True: print("conunt:",count) conunt = conunt +1 注:while:作为循环命令 ...
- 2018-2019-2 20189206 Python3学习
python3简明教程学习 基本概念 脚本文件: 脚本文件英文为Script.实际上脚本就是程序,一般都是由应用程序提供的编程语言.应用程序包括浏览器(javaScript.VBScript).多媒体 ...
- 检测当前运行环境对es6的支持
摘自:http://es6.ruanyifeng.com/#docs/intro 1.查看 node 已经实现的 es6 特性 // Linux & Mac $ node --v8-optio ...
- #分组背包 Educational Codeforces Round 39 (Rated for Div. 2) D. Timetable
2018-03-11 http://codeforces.com/contest/946/problem/D D. Timetable time limit per test 2 seconds me ...