CF924D. Contact ATC

Solution

第一波转化挺妙的。

令tlitl_itli​表示用−w-w−w的风到原点的时间,tritr_itri​表示用www的风到圆点的时间。

显然(i,j)(i,j)(i,j)有解的条件为(tli−tlj)(tri−trj)<=0(tl_i-tl_j)(tr_i-tr_j)<=0(tli​−tlj​)(tri​−trj​)<=0。

然后就变成了二维偏序问题(据说会卡精度,然后就写分数类了)。

Code

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second
#define int llusing namespace std;template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=200005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{int f=1,x=0; char c=getchar();while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }return x*f;
}
int num=0;
struct number { int x,y; } b[MAXN];
bool operator < (number a,number b) { return a.x*b.y<a.y*b.x; }
bool operator == (number a,number b) { return a.x*b.y==a.y*b.x; }
bool operator > (number a,number b) { return a.x*b.y>a.y*b.x; }
pair<number,number> a[MAXN];int s[MAXN<<2],c[MAXN],n,w;
int query(int x) { int ans=0; for (;x;x-=x&(-x)) ans+=s[x]; return ans; }
void add(int x,int y) { for (;x<=n;x+=x&(-x)) s[x]+=y; }
signed main()
{n=read(),w=read();for (int i=1;i<=n;i++){int x=read(),y=read();if (y>0) a[i].fi=(number){-x,y-w},a[i].se=(number){-x,y+w},b[i]=a[i].se;else a[i].fi=(number){x,w-y},a[i].se=(number){x,-y-w},b[i]=a[i].se;}sort(b+1,b+n+1); c[0]=1;for (int i=1;i<=n;i++) if (b[i]==b[i-1]) c[i]=c[i-1];else c[i]=c[i-1]+1;sort(a+1,a+n+1,[&](pair<number,number> x,pair<number,number> y){ return (x.fi<y.fi)||(x.fi==y.fi&&x.se>y.se); });
//  for (int i=1;i<=n;i++) cout<<1.0*a[i].fi.x/a[i].fi.y<<" "<<1.0*a[i].se.x/a[i].se.y<<endl;int ans=0;for (int i=1;i<=n;i++){int t=c[lower_bound(b+1,b+n+1,a[i].se)-b];ans+=query(n)-query(t-1);add(t,1);}printf("%lld\n",ans);return 0;
}

CF924D. Contact ATC相关推荐

  1. Codeforces 924D Contact ATC (看题解)

    Contact ATC 我跑去列方程, 然后就gg了... 我们计每个飞机最早到达时间为L[ i ], 最晚到达时间为R[ i ], 对于面对面飞行的一对飞机, 只要他们的时间有交集则必定满足条件. ...

  2. 2018暑期做题部分整合

    <Matrix>(HDU) 题意:n*m矩阵,每个点可黑可白,问有多少种方案使矩阵至少有A行B列全黑. 思路:第一反应当然是容斥,但是发现a+1行全黑的方案,并不是恰被a行全黑的方案多算a ...

  3. 【航线运输驾驶员理论考试】操作程序

    文章目录 1.Which altitude is appropriate for the floor of Class A airspace?(A类空域的下限高度为) 2.Which altitude ...

  4. usaco contact

    ★Contact 联系 奶牛们开始对用电波望远镜扫描牧场外的宇宙感兴趣.最近,他们注意到了一种非常奇怪的脉冲调 制微波被从星系的中央发射出来.他们希望知道电波是否是被某些地外生命发射出来的,还是仅仅 ...

  5. LSM 优化系列(六)-- 【ATC‘20】MatrixKV : NVM 的PMEM 在 LSM-tree的write stall和写放大上的优化

    文章目录 LSM 问题背景 MatrixKV 设计细节 整体架构介绍 Matrix Container介绍 Receiver RowTable Compactor Space management C ...

  6. 使用postman修改SAP Marketing Cloud contact主数据

    Marketing Cloud里的contact主数据,创建成功后也不是所有字段都能够被修改.在Personal data区域的字段是可以被修改的. 比如我在"客户属性"字段里维护 ...

  7. unable to contact ip driver

    最近在一家客户里发现这样一个情况,域里的计算机突然上不了网,网络连接看起来正常,但是 PING不通,连域用户都没有了,运行PING 或IPCONFIG时会提示: unable to contact i ...

  8. [ASP.NET MVC3.0]Contact Manager 之迭代开发 一

    为什么80%的码农都做不了架构师?>>>    原文地址:http://www.asp.net/mvc/tutorials/iteration-1-create-the-applic ...

  9. Contact Bubble View

    2019独角兽企业重金招聘Python工程师标准>>> 实现类似电子邮件app的地址栏气泡文字(contact bubbles),点击每个气泡文字,会弹出一个小框框,可以对气泡进行进 ...

最新文章

  1. 解决导航守卫router.beforeResolve使用不了this.$store
  2. OnlineJudge在线判题系统
  3. PHP图形图像的典型应用 --常用图像的应用(验证码)
  4. [蓝桥杯][历届试题]九宫重排-双向bfs和map标记
  5. 邻接表2 -试在邻接表存储结构上实现图的基本操作 del_vertex-数据结构-图-icoding
  6. 擦窗机器人不用时怎么收纳_省心省力,智能擦窗机器人
  7. 用Paint Tool SAI绘制漫画
  8. php 设置中文 cookie, js获取
  9. pythoni手机版下载_Python进度栏和下载
  10. python ansible模块_python学习-ansible简单使用1
  11. 2019年3月计算机考试操作,2019年3月计算机二级C++操作练习题(一)
  12. oracle迁移mysql验证_ORACLE 迁移MYSQL 随笔
  13. 使用实例 ---- 使用NUnit在.Net编程中进行单元测试
  14. Integer与int的种种比较你知道多少?
  15. 区分 WDM驱动和NT驱动(有待继续思考)
  16. Qt调用工业相机之相机的触发模式及代码实现
  17. Matlab中mat2str函数使用
  18. 三防平板终端丨三防平板电脑丨三防平板如何应用在工业中?
  19. 微信公众号官网平台与微信公众号第三方平台的区别
  20. java成绩五分制转换_绩点五分制换算(5分制的绩点对照表)

热门文章

  1. 她花了8个月让骗子爱上自己,然后把骗子引到警察局......
  2. 这不是特效也不是魔术!
  3. 原来医生的处方不是随便乱写的...
  4. 这五部关于宇宙的神级纪录片,带你探索未知的外太空世界
  5. 老娘不就是没化妆吗?你几个意思?
  6. AI催生新的工作机遇:5个未来会很吃香的岗位
  7. TED演讲:区块链将如何改变世界?看完太震撼了!
  8. 2017年终奖发放,程序员人均11776元排名第一!
  9. Java学习笔记之 IO包 字节流
  10. bitmap 转byte[]后读取_闲谈redis的bitmap