D - Acute Triangles

思路:

极角排序+点积叉积

在一个三角形中,如果它是直角或者顿角三角形,那么直角和顿角只会出现一次

所以直角和顿角三角形的个数等于直角和顿角的个数

所以锐角三角形的个数等于三元组个数减去直角和顿角的个数

三点共线看成退化的顿角三角形

怎么算直角和顿角个数呢, 先按某个点极角排序,然后暴力过取,用双指针维护到

当前幅角距离为pi/2 到 3*pi/2 的区间, 区间内点的个数就是到当前幅角为直角或顿角的个数

可以用点积和叉积分别判断角度和相对方向

代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-(long double)1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head const int N = 2e3 + ;
struct point {
LL x, y;
point(){}
point(LL x, LL y):x(x), y(y){}
LL dot(point p) {
return x*p.x + y*p.y;
}
LL cross(point p) {
return x*p.y - y*p.x;
}
}p[N], t[N];
bool anglecmp(point a, point b) {
if(a.y <= && b.y > ) return true;
if(a.y > && b.y <= ) return false;
if(!a.y && !b.y) return a.x < b.x;
return a.cross(b) > ;
}
bool acute(point a, point b) {
return a.dot(b) > && a.cross(b) >= ;
}
bool acute2(point a, point b) {
return a.dot(b) > && a.cross(b) < ;
}
int main() {
int T, n;
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for (int i = ; i <= n; i++) scanf("%lld %lld", &p[i].x, &p[i].y);
LL ans = 1LL*n*(n-)*(n-)/;
for (int i = ; i <= n; i++) {
int cnt = ;
for (int j = ; j <= n; j++) {
if(j!=i)
t[++cnt] = point(p[j].x - p[i].x, p[j].y - p[i].y);
}
sort(t+, t++cnt, anglecmp);
int l = , r = ;
for (int j = ; j <= cnt; j++) {
while(l <= cnt && acute(t[j], t[l])) l++;
while(r <= cnt && !acute2(t[j], t[r])) r++;
ans -= r-l;
}
}
printf("%lld\n", ans);
}
return ;
}

2017 Russian Code Cup (RCC 17), Elimination Round D - Acute Triangles的更多相关文章

  1. 2017 Russian Code Cup (RCC 17), Final Round

    2017 Russian Code Cup (RCC 17), Final Round A Set Theory 思路:原题转换一下就是找一个b数组,使得b数组任意两个数的差值都和a数组任意两个数的差 ...

  2. 2016 Russian Code Cup (RCC 16), Final Round B - Cactusophobia

    B - Cactusophobia 思路: 点双联通分量+最大流 用tarjan求出每个点双联通分量 对于大小大于1的点双联通分量,它就是个环,那么源点和这个环相连, 容量为环的大小减一,这个环和环上 ...

  3. [Russian Code Cup 2017 - Finals [Unofficial Mirror]]简要题解

    来自FallDream的博客,未经允许,请勿转载,谢谢. Div1难度+ACM赛制  和几个大佬组队逛了逛 A.给一个大小为n的集合ai(1<=ai<=1000000),要求你构造一个大小 ...

  4. 【CF1146】Forethought Future Cup - Elimination Round

    Forethought Future Cup - Elimination Round 窝也不知道这是个啥比赛QwQ A. Love "A" 给你一个串,你可以删去若干个元素,使得最 ...

  5. CF1146 Forethought Future Cup Elimination Round Tutorial

    CF1146 Forethought Future Cup Elimination Round Tutorial 叮,守夜冠军卡 https://codeforces.com/blog/entry/6 ...

  6. Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)

    Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...

  7. Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words

    Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words https://code.google.com/cod ...

  8. IntelliJ IDEA 2017.3.5 安装 lombok-plugin-0.17 失败,通过网络下载总是超时

    1.问题: IntelliJ IDEA 2017.3.5 安装 lombok-plugin-0.17 失败,通过网络下载总是超时: 2.原因:IntelliJ IDEA 2017.3.5 目前还不支持 ...

  9. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

随机推荐

  1. MOT上海站 | 卓越研发之路:微服务之路

    微服务架构在带来灵活性.扩展性.可用性等优点的同时,其复杂性也给架构师们带来了很大的挑战.当你面对这些挑战一筹莫展时,不妨来参加由msup和微软联合推出的MOT线下沙龙活动吧,我们将给您答疑解惑. M ...

  2. 自定制property

    class Lazyproperty: def __init__(self, func): self.func = func def __get__(self, instance, owner): p ...

  3. PE、PB、PEG三大估值法的正确使用方法!

    目前市面上的估值方法有很多,比如PE估值法.PB估值法.PEG估值法,但是我相信,真正会用的人并不多,比如说目前动态市盈率121倍的比亚迪真的高估吗?比如目前市净率为0.63倍的众泰汽车真的是破净股吗 ...

  4. VBA语法总结

    为了控制Excel,学了些VBA,总结下语法,下文分为五部分: 一.代码组织 二.常用数据类型 三.运算符 四.控制流 五.常用内置函数 一.代码组织 1.能写代码的地方有{模块,类模块}. 2.代码 ...

  5. 关于for循环

    1.普通for循环 (遍历数组的索引值(下标),边界可以自己划定) var arr = [10, 20, 30];for(var i=0; i<arr.length; i++) console. ...

  6. java框架之SpringCloud(1)-微服务及SpringCloud介绍

    微服务概述 是什么 业界大牛 Martin Fowler 这样描述微服务: 参考[微服务(Microservices)-微服务原作者Martin Flower博客翻译]. 下面是关于上述博客中的部分重 ...

  7. [svc]共享内存

    ipc是什么? 进程间通信(IPC,Inter-Process Communication),指至少两个进程或线程间传送数据或信号的一些技术或方法. 进程间为何不能直接共享数据? 如何解决ipc问题? ...

  8. 小学生都能看懂的FFT!!!

    小学生都能看懂的FFT!!! 前言 在创新实践重心偷偷看了一天FFT资料后,我终于看懂了一点.为了给大家提供一份简单易懂的学习资料,同时也方便自己以后复习,我决定动手写这份学习笔记. 食用指南: 本篇 ...

  9. c# Resolve SQlite Concurrency Exception Problem (Using Read-Write Lock)

    This article describes the c# example to solve the problem of SQlite concurrent exception method. To ...

  10. Python基础(一)常用函数

    1.map() 此函数可以,将列表内每一个元素进行操作,并返回列表 原型 map(function,[list]) def fc(x): return x * 2 print(map(fc,[1,2, ...