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. springMVC的常用注解有哪些?

    1.@Controller @Controller 用于标记在一个类上,使用它标记的类就是一个SpringMVC Controller 对象.分发处理器将会扫描使用了该注解的类的方法,并检测该方法是否 ...

  2. 微信小程序 API 网络(ajax)

    网络 API 类似于 ajax 向服务器请求网络地址,唯一不同的是这个请求有很多的规则,且必须向服务器上请求,不能在本地请求 网络 发送请求: wx.request() 发起https网络请求 参数: ...

  3. phpmyadmin普通用户使用配置

    正常情况需求是,普通用户可以管理特定的数据库,可能也需要能新建数据库,配置如下: 1.添加用户,phpmyadmin和应用访问,所以主机设置127.0.0.1访问即可 2.如果只管理一个数据,可以选择 ...

  4. nginx调优buffer参数设置

    内容来自 https://blog.tanteng.me/2016/03/nginx-buffer-params/.有空再详细了解 Nginx性能调优之buffer参数设置 打开Nginx的error ...

  5. 使用collection查询集合属性

    介绍resultMap中使用collection查询集合属性 业务需求,查询部门中的多个人员 public class Department { private Integer id; private ...

  6. 将项目发布到neuxs私服

    需要在 pom.xml中配置 <distributionManagement> <repository> <id>user-release</id> & ...

  7. HTTPS 证书制作及使用

    一 证书的制作 进入jdk/bin,使用keytools.exe制作证书. 1.创建keystore 创建一个别名为serverkeystore的证书,该证书存放在名为server.keystore的 ...

  8. leetcode 27. 移除元素(python)

    1. 题目描述 给定一个数组 nums 和一个值 val,你需要原地移除所有数值等于 val 的元素,返回移除后数组的新长度. 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外 ...

  9. WCF 出现System.Core version 2.0.5.0 未能加载问题

    Window server 2008 R2 Enterprise 版本测试: 需要安装Net补丁: NDP40-KB2468871-v2-x64 下载地址 https://www.microsoft. ...

  10. Python Module_pdb_DEBUG 方法

    目录 目录 pdb pdb 的 Debug 方式 pdb 的调试指令 示例 IPython 自带的 Debug 工具 ipdb pdb pdb 是 Python 自带的程序包,为 Python 程序提 ...