比赛 |
2024国庆练习1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
混乱的齿轮 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
0.044 s |
代码语言 |
C++ |
内存使用 |
3.57 MiB |
提交时间 |
2024-10-04 17:59:14 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 1100;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n,rt,ans;
int x[N],y[N],r[N],v[N],mx;
vector<int>e[N];
int dis(int i,int j){return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);}
int main(){
freopen("rollers.in","r",stdin);
freopen("rollers.out","w",stdout);
n = read();
for(int i = 1;i <= n;i++){
x[i] = read(),y[i] = read(),r[i] = read();
if(!x[i] && !y[i])rt = i;
}
for(int i = 1;i <= n;i++)
for(int j = 1;j <= n;j++)
if(i != j && (r[i] + r[j]) * (r[i] + r[j]) >= dis(i,j))e[i].pb(j);
queue<int>q;
q.push(rt);
while(!q.empty()){
int x = q.front();q.pop();
for(int y : e[x]){
if(v[y])continue;
ans = y;
v[y] = 1;
q.push(y);
}
}
printf("%d %d\n",x[ans],y[ans]);
return 0;
}