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浓度的饮料,问最少需要多少升饮料 [题 ...
随机推荐
- [原] MyBatis 整理
花了一上午的时间,先整理一个脑图.
- windows 下面必备软件
弹窗拦截软件 http://www.pc6.com/pc/tcguanggaolj/
- python基础类型—列表
列表 列表是python中的基础数据类型之一,其他语言中也有类似于列表的数据类型,比如js中叫数组,他是以[]括起来,每个元素以逗号隔开,而且他里面可以存放各种数据类型比如: li = [‘alex’ ...
- 如何使用Vue-cli搭建和运行vue项目
此文章 主要参考:https://jingyan.baidu.com/article/5225f26bbb430fe6fa0908ce.html 在vue init webpack my-proje ...
- 自闭的D7
先是一道**题然后我死了啊. A: 哇人人都会我不会系列. 我们可以运用逆向思维啊,把它转化成若干个人从点1进来, 然后我们考虑深度 dep,用 num[dep] 表示深度大于等于这个点的有多少个, ...
- spfa最短路径
C++代码 #include <iostream> #include <deque> #include <stack> #include <vector> ...
- RTOS 和中断之间要注意的
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRI ...
- 最全的MonkeyRunner自动化测试从入门到精通(5)
夜神模拟器的安装与配置步骤一:我们为什么会选择使用夜神模拟器呢? 众所周知,Android studio的模拟器运行速度也很快,可以媲美真机.虽然其运行速度很快,可以满足我们测试的需求.但仍存在以下问 ...
- pycharm import pygame 出现报错:No module named 'pygame'
首先发现装的Python 有问题原来的Python3.6.4版本安装完成后Scripts文件夹里空白的,什么也没有,从https://www.python.org/downloads/windows/ ...
- Python cffi学习
cffi是连接Python与c的桥梁,可实现在Python中调用c文件.cffi为c语言的外部接口,在Python中使用该接口可以实现在Python中使用外部c文件的数据结构及函数. 由于资料较少,所 ...