当前位置:网站首页>2020 ICPC Asia Taiwan Online Programming Contest C Circles
2020 ICPC Asia Taiwan Online Programming Contest C Circles
2022-06-13 11:02:00 【I can screw the bottle cap when I am born again】
This problem really ignores the process and will be wrong , In the future, I will not write directly with any ideas .
Topic link ++++++++++++++++++++++++
&&&&& I have just given you n Center of circle , After the game starts, the radius of each circle begins to increase at the same rate , When one circle meets another circle, the circle stops growing . In this case , As the circle grows, the radius of other circles will be limited ( This is dynamic , The smallest two circles must stop growing first , Then the other center radii change , Find the minimum value each time , You can use priority queues ), It is not to find the center nearest to each center that is where the growth stops ,
The title is as follows
There are n magical circles on a plane. They are centered at (x1, y1),(x2, y2), . . . ,(xn, yn), respectively. In the beginning, the radius of each circle is 0, and the radii of all magical circles will grow at the same rate. When an magical circle touches another, then it stops growing. Write a program to calculate the total area of all magical circles at the end of growing.
Input description :
The first line contains an integer n to indicate the number of magical circles. The i-th of thefollowing n lines contains two space-separated integers xi and yi indicating that the i-th magicalcircle is centered at (xi , yi).
Output description :
Output the total area of the circles.
Input
Copy
3
0 0
0 1
2 0
Output
Copy
8.639379797371932
Input
Copy
4
0 0
1 0
1 1
0 1
Output
Copy
3.14159265359
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2010;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double pi = acos(-1.0);
struct Node
{
double dis;
int a, b;
bool operator < (const Node &x) const
{
return dis > x.dis;
}
};
priority_queue<Node> Q;
int v[MAXN];
double px[MAXN], py[MAXN], ans[MAXN];
inline double getdis(int a, int b)
{
double X = abs(px[a] - px[b]);
double Y = abs(py[a] - py[b]);
return sqrt(X * X + Y * Y);
}
int main()
{
int n; scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%lf %lf", &px[i], &py[i]);
for(int i = 1; i <= n; ++i)
for(int j = i + 1; j <= n; ++j)
Q.push((Node){
getdis(i, j) / 2.0, i, j});
while(!Q.empty())
{
Node x = Q.top(); Q.pop();
if(v[x.a] && v[x.b]) continue;
else if(!v[x.a] && !v[x.b])
{
v[x.a] = v[x.b] = 1;
ans[x.a] = ans[x.b] = x.dis;
for(int i = 1; i <= n; ++i)
{
if(!v[i]) Q.push((Node){
getdis(x.a, i) - x.dis, x.a, i});
if(!v[i]) Q.push((Node){
getdis(x.b, i) - x.dis, x.b, i});
}
}
else
{
if(v[x.a]) swap(x.a, x.b);
if(abs(x.dis + ans[x.b] - getdis(x.a, x.b)) < EPS)
{
v[x.a] = 1, ans[x.a] = x.dis;
for(int i = 1; i <= n; ++i)
if(!v[i]) Q.push((Node){
getdis(x.a, i) - x.dis, x.a, i});
}
}
}
double sum = 0;
for(int i = 1; i <= n; ++i)
sum += ans[i] * ans[i] * pi;
printf("%.15f\n", sum);
return 0;
}
This question gives me a new way of thinking , frigging awesome !!!!!!!!!
边栏推荐
- 第七章 文件管理作业
- Vivo large scale kubernetes cluster automation operation and maintenance practice
- 避免让转型企业走入歧途,是时候重新理解下湖仓一体了!| Q推荐
- Database learning notes (Chapter 15)
- 状态压缩DP例题(旅行商问题和填矩形问题)
- 数据库学习笔记(第十五章)
- Questions and answers of the labor worker general basic (labor worker) work license in 2022
- Navicat connection MySQL in Pagoda
- 2022 coal mine water exploration and drainage special operation certificate examination question bank simulated examination platform operation
- 2022 Gansu Province safety officer C certificate work certificate title and online simulation examination
猜你喜欢
Use of servers
Vivo large scale kubernetes cluster automation operation and maintenance practice
终于,月入 20000 !!
Go zero microservice Practice Series (III. API definition and table structure design)
宝塔中navicat连接mysql
数位DP例题
什么是400G以太网?
To vent their dissatisfaction with their superiors, Baidu post-95 programmers were sentenced to 9 months for deleting the database
Talk about MySQL indexing mechanism
【20220526】UE5.0.2 release d11782b
随机推荐
Chapter VII document management
网传互联网公司加班表,排名第一的没有悬念!
数据库学习笔记(第十五章)
Web3 system construction: principles, models and methods of decentralization (Part I)
Prim求最小生成树(朴素版稠密图)
硬件工程师薪资虚高,你认可吗?
EasyClick 运行代码片段出Null
微众银行OSPO建设之路:如何通过OSPO的建设推动企业开源?
什么是400G以太网?
AcWing第 55 场周赛
Chapter VI i/o management
[dynamic planning] beginner level
宝塔中查看mysql默认密码
21世纪以来的历次“粮食危机”,发生了什么?
ue5 小知识点 geometry script modeling
Full stack development practice | integrated development of SSM framework
很妙的贪心(F2. Nearest Beautiful Number (hard version))
文件夹数据同步工具Sync Folders Pro
第六章 I/O管理作业
Nim游戏阶梯 Nim游戏和SG函数应用(集合游戏)