제출 #1102656

#제출 시각아이디문제언어결과실행 시간메모리
1102656huantranOdašiljači (COCI20_odasiljaci)C++17
0 / 70
2 ms340 KiB
#include <bits/stdc++.h> // #define bit(x, i) using namespace std; const int maxn = 1e3 + 5; typedef long double ll; int n; vector<tuple<ll, ll, ll>> edge; vector<tuple<ll, ll, ll>> point; int par[maxn]; ll dis(ll a, ll b, ll c, ll d) { return sqrt((a - c)*(a - c) + (b - d)*(b - d)); } int find_par(int u) { return (u == par[u]) ? u : par[u] = find_par(par[u]); } void make_union(int u) { par[u] = u; } int merge_union(int u, int v) { u = find_par(u); v = find_par(v); if (u == v) { return false; } par[u] = v; return true; } int main() { #ifndef ONLINE_JUDGE freopen("TASK.inp", "r", stdin); freopen("TASK.out", "w", stdout); #endif // ONLINE_JUDGE ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { make_union(i); } for (int i = 1; i <= n; i++) { ll a, b; cin >> a >> b; point.emplace_back(a, b, i); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { auto [a, b, p1] = point[i]; auto [c, d, p2] = point[j]; ll len = dis(a, b, c, d); edge.emplace_back(len, p1, p2); } } sort(edge.begin(), edge.end()); ll cost = 0.0; int num = 0; for (auto [w, u, v] : edge) { if (merge_union(u, v)) { cost = max(cost, w); num++; } if (num == n - 1) break; } cout << fixed << setprecision(9) << cost/2.0; }

컴파일 시 표준 에러 (stderr) 메시지

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         freopen("TASK.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
odasiljaci.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen("TASK.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...