Codeforces 333E Summer Earnings(bitset)
题目链接 Summer Earnings
类似MST_Kruskal的做法,连边后sort。
然后对于每条边,依次处理下来,当发现存在三角形时即停止。(具体细节见代码)
答案即为发现三角形时当前所在边长度的一半。
#include <bits/stdc++.h>
using namespace std;
struct node{
int x, y, z;
friend bool operator < (const node &a, const node &b){
return a.z > b.z;
}
} p[4600010];
int a[3010], b[3010];
int n, cnt = 0;
bitset <3010> c[3010], tmp;
int main(){
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d%d", a + i, b + i);
for (int i = 1; i <= n - 1; ++i) for (int j = i + 1; j <= n; ++j)
p[++cnt].x = i, p[cnt].y = j,
p[cnt].z = (a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]);
sort(p + 1, p + cnt + 1);
for (int i = 1; i <= cnt; ++i){
int x = p[i].x, y = p[i].y;
tmp = c[x] & c[y];
if (tmp.any()) return 0 * printf("%.10f\n", sqrt(1.00 * p[i].z) / 2);
c[x].set(y), c[y].set(x);
}
return 0;
}
Codeforces 333E Summer Earnings(bitset)的更多相关文章
- Codeforces 632F Magic Matrix(bitset)
题目链接 Magic Matrix 考虑第三个条件,如果不符合的话说明$a[i][k] < a[i][j]$ 或 $a[j][k] < a[i][j]$ 于是我们把所有的$(a[i][j ...
- 【CF1097F】Alex and a TV Show(bitset)
[CF1097F]Alex and a TV Show(bitset) 题面 洛谷 CF 题解 首先模\(2\)意义下用\(bitset\)很明显了. 那么问题在于怎么处理那个\(gcd\)操作. 然 ...
- Codeforces I. Producing Snow(优先队列)
题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 3687: 简单题(bitset)
3687: 简单题 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 700 Solved: 319[Submit][Status][Discuss] ...
- [Bzoj5285][洛谷P4424][HNOI/AHOI2018]寻宝游戏(bitset)
P4424 [HNOI/AHOI2018]寻宝游戏 某大学每年都会有一次Mystery Hunt的活动,玩家需要根据设置的线索解谜,找到宝藏的位置,前一年获胜的队伍可以获得这一年出题的机会. 作为新生 ...
- Codeforces Gym101341K:Competitions(DP)
http://codeforces.com/gym/101341/problem/K 题意:给出n个区间,每个区间有一个l, r, w,代表区间左端点右端点和区间的权值,现在可以选取一些区间,要求选择 ...
- 【科技】位运算(bitset)优化最长公共子序列算法
最长公共子序列(LCS)问题 你有两个字符串 \(A,B\),字符集为 \(\Sigma\),求 \(A, B\) 的最长公共子序列. 简单动态规划 首先有一个广为人知的 dp:\(f_{i,j}\) ...
- Codeforces 1500F - Cupboards Jumps(set)
Codeforces 题面传送门 & 洛谷题面传送门 nb tea!!!111 首先很显然的一件事是对于三个数 \(a,b,c\),其最大值与最小值的差就是三个数之间两两绝对值的较大值,即 \ ...
- Atcoder Regular Contst 084 D - XorShift(bitset)
洛谷题面传送门 & Atcoder 题面传送门 没错,这就是 Small Multiple 那场的 F,显然这种思维题对我来说都是不可做题/cg/cg/cg 首先如果我们把每个二进制数看作一个 ...
随机推荐
- Python爬虫一
爬虫 什么是爬虫? 网络爬虫(又被称为网页蜘蛛,网络机器人)就是模拟客户端发送网络请求,接收请求响应, 一种按照一定的规则,自动地抓取互联网信息的程序. 原则上,只要是浏览器(客户端)能做的事情,爬虫 ...
- poj-2488 a knight's journey(搜索题)
Time limit1000 ms Memory limit65536 kB Background The knight is getting bored of seeing the same bla ...
- vagrant中的precise64使用静态的能和host所在局域网的其他机器互相通信
vagrant中的precise64使用静态的能和host所在局域网的其他机器互相通信
- day05 模块以及内置常用模块用法
内置常用模块详解: 1 time 2 datetime 3 random 4 os 5 sys 6 shutil 7 shelve 8 xml 9 configparser 10 hashlib ...
- cf963b Destruction of a Tree
越靠近叶子越优先删掉 #include <iostream> #include <vector> #include <cstdio> using namespace ...
- day05_04 数据类型-数值、布尔值、字符串简介
数据运算 数据类型初识 数字 整数 int(integer) 整型 长整型 在python3里面已经不区分整型和长整型了,统一都叫整型 在32位机器上,整数的位数为32位,取值范围为-2**31-2* ...
- day03_07 变量的重新赋值01
在cmd中退出python,需要使用quit()命令 name = "Alex Li" name2 = name print(name,name2) name = "Ja ...
- AutoEncoder and DenoiseAutoEncoder
AutoEncoder and DenoiseAutoEncoder 第一部分 首先我们将实现一个如上图结构的最简单的AutoEncoder. 加载数据 在这里,我们使用MNIST手写数据集来进行实验 ...
- 当网络中断的时候,JTA全局事务管理,究竟会不会回滚???
前言:有人问了我一个问题,就是说在网络中断的时候,JTA的全局事务管理,会不会回滚?当时说会回滚,但没给对方说清楚理由,也不太认同我的观点.现在总结一下. 今天一天都在看文档(也查了一些博客和网站), ...
- 九度oj 题目1041:Simple Sorting
题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill p ...