当前位置:网站首页>uva1421
uva1421
2022-07-27 20:09:00 【Stab the bear with a knife】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 5005;
const double ex = 1e-7;
int w,n;
struct Node {
double d, l, r;
bool operator<(const Node& input) {
return d < input.d;
}
}node[maxn];
int check(double x) {
double l = atan2(node[0].d, node[0].r - x), r = atan2(node[0].d, node[0].l - x);
for (int i = 1; i < n; i++) {
double ll = atan2(node[i].d, node[i].r - x);
double rr = atan2(node[i].d, node[i].l - x);
// The current angle is too big It needs to be moved to the right to become smaller
if (ll - r > ex) return 1;
// The current angle is too small Need to move left to get bigger
if (rr - l < -ex) return -1;
l = max(ll, l);
r = min(rr, r);
}
// Can wear
return 0;
}
bool IsOk() {
double l = 0, r = w;
while (r - l > ex) {
double mid = (r + l) / 2;
int ret = check(mid);
if (ret == 0)return true;
else if (ret == 1) l = mid;
else r = mid;
}
return false;
}
int main()
{
int t;
cin >> t;
while (t--) {
cin >> w >> n;
for (int i = 0; i < n; i++) {
cin >> node[i].d >> node[i].l >> node[i].r;
}
sort(node, node + n);
if (IsOk())cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
边栏推荐
猜你喜欢

Hacker introductory tutorial (very detailed) from zero basic introduction to proficiency, it is enough to read this one.

统一建模语言 (UML) 规范

mysql函数汇总之系统信息函数

十年测试老鸟聊聊移动端兼容性测试

ms721负载测试
![In a real case, college students were cheated when taking orders. I hope you won't be cheated [painful lesson]](/img/7d/142e69d6da1899cefbcc99d7929fba.png)
In a real case, college students were cheated when taking orders. I hope you won't be cheated [painful lesson]

新库上线 | CnOpenData中国全部专利详细地址数据

Underlying principle of mvcc

真实案例,大学生接单被骗,希望大家不要被骗了【惨痛教训】

Rodin installs the SMT solvers plug-in
随机推荐
Datepicker and TimePicker
[paper reading] rich feature hierarchies for accurate object detection and semantic segmentation
Software configuration | tigervnc download, installation and configuration
C191:密码编译
JS 数组方法 forEach 和 map 比较
Talk about how redis handles requests
Static test. 2021.01 .13
sqlite创建表联合主键的sql写法
函数优先顺序
[Redis] Redis穿透、雪崩和击穿
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xff in position 0: invalid start byte
1.2 pedestrian recognition based on incremental generation of occlusion and confrontation suppression (code understanding and experimental progress + Report)
软件配置 | tigerVNC的下载、安装及配置
[Redis] Redis几种部署方式
libpcap库和pcap_sendpacket接口函数了解
C170: retest screening
2022爱分析·智慧社区厂商全景报告 厂商征集
Built in module 10.18
内置函数时间日期函数
会员卡头部组件使用文档