Codeforces 333E Summer Earnings - bitset
显然答案是三点间任意两点之间的距离的最小值的一半。
那么一定有一对点的距离会被算入答案。
考虑将所有边按距离从大到小排序。当加入某一条边的时候出现了三元环。那么这条边的长度的一半就是答案。
至于判断三元环就用bitset。再加上很难跑满,以及for自带二分之一常数就过了。
标算是二分答案,然后枚举一个点,保留距离和它大于等于$mid$的所有点,求一个凸包然后判断之间最远点对的距离是否大于等于$mid$。
时间复杂度$O(n^{2}\log V)$,常数比较大,可能会比较卡,需要特殊卡常技巧。
由于答案一定与某一条边的长度有关,所以应该可以二分是哪一条边来减小常数。
Code
/**
* Codeforces
* Problem#333E
* Accepted
* Time: 2246ms
* Memory: 142056k
*/
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <ctime>
using namespace std;
typedef bool boolean;
#define ll long long typedef class Point {
public:
int x, y;
}Point; ll dis2(Point a, Point b) {
return (a.x - b.x) * 1ll * (a.x - b.x) + (a.y - b.y) * 1ll * (a.y - b.y);
} typedef class Data {
public:
int x, y;
ll dis; boolean operator < (Data b) const {
return dis > b.dis;
}
}Data; int n, m;
ll res = ;
Point* ps;
Data* ds;
bitset<> *bs; inline void init() {
scanf("%d", &n);
ds = new Data[(n * n + )];
ps = new Point[(n + )];
bs = new bitset<>[(n + )];
for (int i = ; i <= n; i++)
scanf("%d%d", &ps[i].x, &ps[i].y);
} inline void solve() {
for (int i = ; i <= n; i++)
for (int j = i + ; j <= n; j++)
++m, ds[m].x = i, ds[m].y = j, ds[m].dis = dis2(ps[i], ps[j]);
sort(ds + , ds + m + );
for (int i = ; i <= m; i++) {
int x = ds[i].x, y = ds[i].y;
if ((bs[x] & bs[y]).count()) {
printf("%.9lf", sqrt(ds[i].dis) / );
return;
}
bs[x][y] = , bs[y][x] = ;
}
puts("");
} int main() {
init();
solve();
return ;
}
Codeforces 333E Summer Earnings - bitset的更多相关文章
- Codeforces 333E Summer Earnings ——Bitset
[题目分析] 找一个边长最大的三元环. 把边排序,然后依次加入.加入(i,j)时,把i和j取一个交集,看看是否存在,存在就找到了最大的三元环. 输出即可,n^3/64水过. [代码] #include ...
- Codeforces 333E Summer Earnings(bitset)
题目链接 Summer Earnings 类似MST_Kruskal的做法,连边后sort. 然后对于每条边,依次处理下来,当发现存在三角形时即停止.(具体细节见代码) 答案即为发现三角形时当前所在边 ...
- CodeForces 333E. Summer Earnings
time limit per test 9 seconds memory limit per test 256 megabytes input standard input output standa ...
- Codeforces 232E - Quick Tortoise bitset+分治
题意: 思路: //By SiriusRen #include <cstdio> #include <bitset> #include <vector> using ...
- Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- codeforces 707D-(DFS+bitset)
题目链接:http://codeforces.com/contest/707/problem/D 根据询问建立一棵树然后DFS. #include<bits/stdc++.h> using ...
- Codeforces Gym 100342J Problem J. Triatrip bitset 求三元环的数量
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/att ...
- Codeforces 917F Substrings in a String - 后缀自动机 - 分块 - bitset - KMP
题目传送门 传送点I 传送点II 传送点III 题目大意 给定一个字母串,要求支持以下操作: 修改一个位置的字母 查询一段区间中,字符串$s$作为子串出现的次数 Solution 1 Bitset 每 ...
- Codeforces 788C The Great Mixing(背包问题建模+bitset优化或BFS)
[题目链接] http://codeforces.com/problemset/problem/788/C [题目大意] 给出一些浓度的饮料,要求调出n/1000浓度的饮料,问最少需要多少升饮料 [题 ...
随机推荐
- Kali Linux安装
Kali Linux 安装过程参考:https://blog.csdn.net/qq_40950957/article/details/80468030 安装完成后,apt-get install 安 ...
- poj 2420
太虚假了. 我为什么要手贱点开submission? 这道题两天之前被一个学弟A了. ? 我退役了. 其实就是爬山吧..好像有的题解还分方向什么的完全没必要吧. #include <iostre ...
- 8、路由 router
路由:router 用户功能 /user ----> index.html /user/login ----> login.html /user/reg ----> reg.html ...
- STL之pair对组
#include<iostream> #include<algorithm> #include<cstring> #include<cstdlib> u ...
- Java基础&面向对象(二)
(七)函数 1.数的定义:具有特定功能的一段小程序,也称为方法: 2.函数的特点: 3.函数的应用:结果.是否需要未知内容参与运算: 4.函数的重载:在同一个类中,允许存在一个以上的同名函数,只要它们 ...
- 剑指offer——python【第56题】删除链表中的重复节点
题目描述 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针. 例如,链表1->2->3->3->4->4->5 处理后 ...
- INFO Dispatcher:42 - Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir
INFO Dispatcher:42 - Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax ...
- HTML、CSS知识点,面试开发都会需要--No.3 盒子模型
No.3 盒子模型 1.盒子模型属性 (1)包含的CSS属性:width.height.padding.border.margin. 1.盒子模型属性 (1)包含的CSS属性: width.heigh ...
- 终于等到你!WebOptimizer - A bundler and minifier for ASP.NET Core
迷人的 ASP.NET Core 有一个美中不足之处,自从一开始接触它到现在,我就一直不喜欢,一直想找到替代品,甚至想过自己实现一个,它就是 BundlerMinifier . 昨天面对 bundle ...
- DM
Chapter1 propositon Logic 1.1propositon A declarative sentence With a unique value. A proposition ca ...