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. Java之Integer类

    Integer类简介: Integer类是基本数据类型int的包装器类,是抽象类Number的子类,位于java.lang包中. Integer类在对象中包装了一个基本类型int的值,也就是每个Int ...

  2. SQL Server 2016升级迁移过程中性能问题诊断案例

    日常运行的批量更新作业,平日是5分钟之内结束,今天出现超过30分钟没结束的情况,实际运行3个小时以上,应用程序超时报错. 数据库版本:SQL Server 2016企业版 问题SQL: declare ...

  3. 系统性能信息模块--psutil

    #安装psutil模块#pip install psutil -i https://pypi.doubanio.com/simple #导入psutil模块import psutilimport da ...

  4. mysql高水位问题解决办法

    数据库中有些表使用delete删除了一些行后,发现空间并未释放产生原因:类比Oracle的高水位线产生原理 delete 不会释放文件高水位 truncate会释放 ,实际是把.ibd文件删掉了,再建 ...

  5. MySql 使用递归函数时遇到的级联删除问题

    以下两段SQL的写法看似相同,结果效果却是不同的 写法A: DELETE OM_ORGANIZATION, OM_POSITION FROM OM_ORGANIZATION LEFT JOIN OM_ ...

  6. 构造Map并对其排序

    #构造Map并对其排序 attr_tul = ['a','b','c','d','e','f'] one_tul = [,,,,,] one_dic = {} for i in range(len(a ...

  7. JavaScript-W3School-Browser 对象:Window open() 方法

    ylbtech-JavaScript-Runoob-Browser 对象:Window open() 方法 1.返回顶部 1. Window open() 方法  Window 对象 定义和用法 op ...

  8. Visual Studio Code 折叠代码快捷键

    为了快速阅读不熟悉的代码, 最好可以打开一个文件能先将具体实现折叠起来的,进行一个大概的认识,vscode中有这些折叠快捷键: ctrl+shift+[是折叠 ctrl+k ctrl+0 是折叠全部 ...

  9. webService框架CXF的简单使用

    最近本来已经将上一个项目交活,全身心投入了另外项目的前端的开发工作.可之前的项目经理通知我,之前的项目需要做一个webService的功能,于是稍微做了一下webService,可是忘了通知我现在的项 ...

  10. 简述在Vue脚手架中,组件以及父子组件(非父子组件)之间的传值

    1.组件的定义 组成: template:包裹HTML模板片段(反映了数据与最终呈现给用户视图之间的映射关系) 只支持单个template标签: 支持lang配置多种模板语法: script:配置Vu ...