Codeforces 333E Summer Earnings ——Bitset
【题目分析】
找一个边长最大的三元环。
把边排序,然后依次加入。加入(i,j)时,把i和j取一个交集,看看是否存在,存在就找到了最大的三元环。
输出即可,n^3/64水过。
【代码】
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath> #include <set>
#include <bitset>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>
#include <queue> using namespace std; #define maxn 3010
#define mlog 16
#define F(i,j,k) for (int i=j;i<=k;++i)
#define inf (0x3f3f3f3f) int Getint()
{
int x=0,f=1; char ch=getchar();
while (ch<'0'||ch>'9') {if (ch=='-') f=-1; ch=getchar();}
while (ch>='0'&&ch<='9') {x=x*10+ch-'0'; ch=getchar();}
return x*f;
} struct edge{int l,r;double d;}e[maxn*maxn];
struct Point{int x,y;}a[maxn];
int n,cnt=0;
bool cmp(edge x,edge y){return x.d>y.d;}
bitset <maxn> b[maxn]; int main()
{
n=Getint();
F(i,1,n)
{
a[i].x=Getint();
a[i].y=Getint();
}
F(i,1,n-1)
F(j,i+1,n)
{
e[++cnt].l=i;
e[cnt].r=j;
e[cnt].d=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
}
sort(e+1,e+cnt+1,cmp);
F(i,1,cnt)
{
if ((b[e[i].l]&b[e[i].r]).count())
{
printf("%.20f\n",e[i].d/2);
return 0;
}
b[e[i].l][e[i].r]=1;
b[e[i].r][e[i].l]=1;
}
}
Codeforces 333E Summer Earnings ——Bitset的更多相关文章
- Codeforces 333E Summer Earnings - bitset
题目传送门 传送门I 传送门II 传送门III 题目大意 给定平面上的$n$个点,以三个不同点为圆心画圆,使得圆两两没有公共部分(相切不算),问最大的半径. 显然答案是三点间任意两点之间的距离的最小值 ...
- 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浓度的饮料,问最少需要多少升饮料 [题 ...
随机推荐
- 明白这十个故事-->你也就参悟了人生 .
1.断箭 不相信自己的意志,永远也做不成将军. 春秋战国时代,一位父亲和他的儿子出征打仗.父亲已做了将军,儿子还只是马前卒.又一阵号角吹响,战鼓雷鸣了,父亲庄严地托起一个箭囊,其中插着一只箭.父亲郑 ...
- fgetc, fgets, getc, getchar, gets, ungetc - 输入字符和字符串
总览 (SYNOPSIS) #include <stdio.h> int fgetc(FILE *stream); char *fgets(char *s, int size, FILE ...
- python中的循环语句-01
接触python已经一周时间,下面针对这一周python学习的情况做一梳理: 1)单行注释,使用一个#:多行注释,使用三个单引号(或者三个双引号)如: name = input("name: ...
- linux 常用命令(持续更新)
查看IP地址 ifconfig 查看TCP端口 netstat -ntlp vi 文本编辑 (1)进入vi编辑模式 在vi的默认模式中,直接在界面中输入: i 在光标所在位置开始编辑: a 在光标所在 ...
- 搭建SSI开发框架原理
Spring2.5.Struts2.Ibatis开发框架搭建(一) ssi, ibatis 一.框架下载 1.1 Struts2框架 Struts2框架发展于WebWork,现在捐献给了Apach ...
- UISearchBar的应用
当你在seachBar中输入字母之前的时候,只是用鼠标选中searchBar的时候,如图 终端输出截图如下:(这个时候调用先shouldBeginEditing,之后调用didBeginEditing ...
- CF-1111 (2019/2/7 补)
CF-1111 题目链接 A. Superhero Transformation tags : strings #include <bits/stdc++.h> using namespa ...
- Linux下安装以及使用MySQL数据库
1.官网下载mysql数据库:https://dev.mysql.com/downloads/mysql/ 2.linux 下可直接下载:wget https://cdn.mysql.com//Dow ...
- MySQL 上移/下移/置顶
在编写网站系统时,难免会用到上移.下移.置顶的功能,今天小编就介绍一下我的思路. 首先,需要一张数据表: CREATE TABLE `a` ( `id` ) NOT NULL AUTO_INCREME ...
- Spring Cloud Stream在同一通道根据消息内容分发不同的消费逻辑
应用场景 有的时候,我们对于同一通道中的消息处理,会通过判断头信息或者消息内容来做一些差异化处理,比如:可能在消息头信息中带入消息版本号,然后通过if判断来执行不同的处理逻辑,其代码结构可能是这样的: ...