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+ ...
随机推荐
- MATLAB变量
序言 在Matlab中,变量名由A~Z.a~z.数字和下划线组成,且变量的第一个字符必须是字母. 尽管变量名可以是任意长度, 但是Matlab只识别名称的前N=namelengthmax个字符, 这里 ...
- android studio java: -source 1.6 中不支持 switch 中存在字符串 的错误
F4打开open moudle setting 将source Compatibility 改为1.7 F4打开open moudle setting 将targetCompatibility 改为1 ...
- PHP on CentOS (LAMP) and wordpress
http://php.net/manual/zh/install.windows.php https://www.unixmen.com/install-wordpress-centos-7-linu ...
- 网络请求(I)
NSURLSession 代理方法 有的时候,我们可能需要监听网络请求的过程(如下载文件需监听文件下载进度),那么就需要用到代理方法. #import "ViewController.h&q ...
- C#-MVC-Razor视图引擎及解决路径问题的三个方法
Razor 视图引擎 与Aspx开发区别在于代码: 1.Razor 更智能,摒弃了<%%>格式,直接用@符号开启cs代码,遇到html时自动识别 2.遇到如汉字等即非cs代码,又非html ...
- (Review cs231n) BN and Activation Function
CNN网络的迁移学习(transfer learning) 1.在ImageNet上进行网络的预训练 2.将最上方的层,即分类器移除,然后将整个神经网络看成是固定特征提取器来训练,将这个特征提取器置于 ...
- cxf配置
先记录一下,后期补充配置原因 原先的spring3.X(struts2)的时候配置cxf2.x没问题,基本就是在context.xml中加入 <import resource="cla ...
- 虚拟机下Linux安装jdk
1.利用共享文件夹复制本地硬盘下(H:/share)的压缩包到指定目录 cp jdk-8u161-linux-x64.tar.gz /soft/jdk 2.进入/soft/jdk目录下,解压jdk到当 ...
- Docker Kubernetes Volume 本地数据卷
Docker Kubernetes Volume 本地数据卷 emptyDir 当Pod分配到Node时,首先创建一个空卷,并挂载到Pod中的容器. Pod中的容器可以读取和写入卷中的文件. 当Pod ...
- G711 G723 G729线路占多少带宽问题
G.711 G.711 也称为PCM(脉冲编码调制),是国际电信联盟订定出来的一套语音压缩标准,主要用于电话.它主要用脉冲编码调制对音频采样,采样率为8k每秒.它利用一个 64Kbps 未压缩 ...