A

B

C

D

给你N个点 问你能不能有两条直线穿过这N个点

首先假设这N个点是可以被两条直线穿过的 所以两条直线就把这N个点划分成两个集合

我们取1 2 3三个点这样必定会有两个点在一个集合内 check一下 如果不满足输出NO

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int n;
struct Point
{
ll x, y;
Point operator - (const Point& p) const
{
return {x - p.x, y - p.y};
}
} p[];
inline bool cross(Point a, Point b)
{
return a.y * b.x == a.x * b.y;
}
inline bool collinear(int x, int y, int z)
{
return cross(p[x] - p[y], p[x] - p[z]);
}
int check(int x, int y)
{
vector<int> todo;
for (int i = ; i <= n; i++)
{
if (!collinear(x, y, i))
{
todo.pb(i);
}
}
if (todo.size() <= )
{
return ;
}
int now1, now2;
now1 = todo[], now2 = todo[];
for (auto i : todo)
{
if (!collinear(now1, now2, i))
{
return ;
}
}
return ;
}
int main()
{
cin >> n;
for (int i = ; i <= n; i++)
{
scanf("%lld %lld", &p[i].x, &p[i].y);
}
if (n <= )
{
cout << "YES" << endl;
return ;
}
int flag = ;
flag |= check(, );
flag |= check(, );
flag |= check(, );
if (flag)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
return ;
}

E

给你N个系列的电视剧 第i个系列有ai集 问你a[i]>=j&&a[j]>=i 这样的对数有多少对

考察一个递增思想 我们i从1循环到N 删去树状数组里集数为i的 这样下一次求的时候数组里就都是满足条件的了(开始的时候因为条件ai>=1 所以update(i,1))

(ai=min(ai,n) ai大于N的时候直接可以赋成N)

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll n;
ll num[];
ll t[];
vector<int> number[];
int lowbit(int x)
{
return x & (-x);
}
void update(int x, ll p)
{
while (x <= n)
{
t[x] += p;
x += lowbit(x);
}
return;
}
ll sum(int k)
{
ll ans = ;
while (k > )
{
ans += t[k];
k -= lowbit(k);
}
return ans;
}
int main()
{
cin >> n;
for (int i = ; i <= n; i++)
{
scanf("%lld", &num[i]);
num[i] = min(num[i], n);
number[num[i]].pb(i);
update(i, );
}
ll anser = ;
for (int i = ; i <= n; i++)
{
anser += sum(num[i]);
for (auto j : number[i])
{
update(j, -);
}
}
for (int i = ; i <= n; i++)
{
if (num[i] >= i)
{
anser--;
}
}
cout << anser / << endl;
return ;
}

Codeforces 961 容斥叉积判共线 树状数组递增思想题的更多相关文章

  1. poj 3321:Apple Tree(树状数组,提高题)

    Apple Tree Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18623   Accepted: 5629 Descr ...

  2. hdu 1541/poj 2352:Stars(树状数组,经典题)

    Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  3. Codeforces 703D Mishka and Interesting sum(树状数组+扫描线)

    [题目链接] http://codeforces.com/contest/703/problem/D [题目大意] 给出一个数列以及m个询问,每个询问要求求出[L,R]区间内出现次数为偶数的数的异或和 ...

  4. CF Educational Codeforces Round 10 D. Nested Segments 离散化+树状数组

    题目链接:http://codeforces.com/problemset/problem/652/D 大意:给若干个线段,保证线段端点不重合,问每个线段内部包含了多少个线段. 方法是对所有线段的端点 ...

  5. Educational Codeforces Round 10 D. Nested Segments 离线树状数组 离散化

    D. Nested Segments 题目连接: http://www.codeforces.com/contest/652/problem/D Description You are given n ...

  6. CodeForces 380C Sereja and Brackets(扫描线+树状数组)

    [题目链接] http://codeforces.com/problemset/problem/380/C [题目大意] 给出一个括号序列,求区间内左右括号匹配的个数. [题解] 我们发现对于每个右括 ...

  7. Educational Codeforces Round 10 D. Nested Segments 【树状数组区间更新 + 离散化 + stl】

    任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds mem ...

  8. Codeforces 703D Mishka and Interesting sum 离线+树状数组

    链接 Codeforces 703D Mishka and Interesting sum 题意 求区间内数字出现次数为偶数的数的异或和 思路 区间内直接异或的话得到的是出现次数为奇数的异或和,要得到 ...

  9. codeforces 869 E. The Untended Antiquity(树状数组)

    题目链接:http://codeforces.com/contest/869/problem/E 题解:这题是挺好想到solution的但是不太好写,由于题目的特殊要求每个矩形不会重贴所以只要这两个点 ...

随机推荐

  1. 后盾网lavarel视频项目---lavarel中间件(使用中间件拦截没登录的用户)

    后盾网lavarel视频项目---lavarel中间件(使用中间件拦截没登录的用户) 一.总结 一句话总结: 1.中间件中验证用户是否登录:if(!Auth::guard('admin')->c ...

  2. npm 错误记录

    npm run dev iview-weapp@1.1.0 dev /Users/Jovins/Desktop/小程序/iview-weapp gulp --gulpfile build/build- ...

  3. 一、基础篇--1.1Java基础-抽象类和接口的区别

    抽象类和接口的区别 抽象类和接口在设计层面的区别主要体现在:接口是对动作的抽象,抽象类是对根源.类的抽象.抽象类表示的是,这个对象是什么,接口表示的是,这个对象可以做什么. 比如,男人.女人是人,人是 ...

  4. Python Module_openpyxl_处理Excel表格

    目录 目录 前言 软件系统 Install openpyxl module Sample code load_workbook加载Excel文件 wbObjectget_sheet_names 获取E ...

  5. app测试和web测试的区别

    单纯从功能测试的层面上来讲的话,APP 测试.web 测试 在流程和功能测试上是没有区别的根据两者载体不一样,则区别如下:1.系统结构方面 web项目,b/s架构,基于浏览器的:web测试只要更新了服 ...

  6. Intellij Idea使用教程汇总篇

    Java编程强大的工具IDEA使用教程及一些快捷键收藏如下: https://blog.csdn.net/fanrenxiang/article/details/80503490

  7. Linux 系统安装 python

    Centos 7 Centos 7 安装 python3 (不要卸载python2 因为yum 要用) https://phoenixnap.com/kb/how-to-install-python- ...

  8. 【Linux开发】为qt-embedded添加jpeg库的交叉编译方法for arm

    看了一个文章: =====================================谢论坛内各位的帮助,我的qt/e2.3.10和qtopia2.1.1终于全部编译通过. 下面是jpeg和uui ...

  9. 大二 Java上学期总结

    一学期的Java学习结束了,这学期对程序语言的理解更深了,首先感谢李津老师的教导,这学期收获挺多的,不像上学期,这学期没有任何缺课表现,希望之后的语言程序学习会更加努力. 突然感觉Java的学习如此之 ...

  10. maven中央仓库太慢的解决办法

    在.m2目录下创建settings.xml文件,文件内容如下: <?xml version="1.0" encoding="UTF-8"?> < ...