| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 374331 | topovik | Odašiljači (COCI20_odasiljaci) | C++14 | 264 ms | 33356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N = 1e6 + 100;
const ll oo = 1e9 + 7;
int pred[N], r[N];
ld dist(ld x, ld y, ld x1, ld y1)
{
return sqrt(pow(x - x1, 2) + pow(y - y1, 2));
}
int cmp(int x)
{
if (x == pred[x]) return x;
else return pred[x] = cmp(pred[x]);
}
void unite(int x, int y)
{
if (r[x] > r[y]) pred[y] = x;
else
{
pred[x] = y;
r[y] += (r[x] == r[y]);
}
}
int main()
{
int n;
cin >> n;
ld x[n], y[n];
for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
vector <pair<ld, pair<int, int> > > qur;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (i != j) qur.pb({dist(x[i], y[i], x[j], y[j]), {i, j}});
for (int i = 0; i < n; i++) pred[i] = i, r[i] = 0;
sort(qur.begin(), qur.end());
int cn = 0;
cout << setprecision(7) << fixed;
for (int i = 0; i < qur.size(); i++)
{
int x = qur[i].s.f, y = qur[i].s.s;
if (cmp(x) != cmp(y))
{
cn++;
unite(cmp(x), cmp(y));
if (cn == n - 1)
{
cout << (qur[i].f / (ld)2) << endl;
return 0;
}
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
