Submission #480384

# Submission time Handle Problem Language Result Execution time Memory
480384 2021-10-16T02:36:08 Z PurpleCrayon Odašiljači (COCI20_odasiljaci) C++17
42 / 70
80 ms 11980 KB
#include <bits/stdc++.h>
using namespace std;
 
#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int MAXN = 1e3+10, MOD = 1e9+7;

struct DSU {
	vector<int> p, sz;
	void init(int n){ p.resize(n); sz.assign(n, 1); iota(p.begin(), p.end(), 0); }
	int find_set(int v){ return v==p[v]?v:p[v]=find_set(p[v]); }
	bool union_sets(int a, int b){
		if ((a=find_set(a))==(b=find_set(b))) return false;
		if (sz[a] < sz[b]) swap(a, b);
		p[b]=a, sz[a]+=sz[b], sz[b]=0;
		return true;
	}
} d;

int n;
ar<ll, 2> a[MAXN];
ar<ll, 3> e[MAXN*MAXN];

ll sq(ll x){ return x*x; }
int dist(int i, int j) {
    return sq(a[i][0]-a[j][0]) + sq(a[i][1]-a[j][1]);
}
void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
    int m = 0;
    for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) {
        e[m++] = {dist(i, j), i, j};
    }
    sort(e, e+m);
    ll ans = 0;
    d.init(n);
    for (int i = 0; i < m; i++) if (d.union_sets(e[i][1], e[i][2])) ans = max(ans, e[i][0]);
    cout << fixed << setprecision(7) << sqrtl(ans) / 2. << '\n';
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int T=1;
    // cin >> T;
    while (T--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Incorrect 1 ms 332 KB Output isn't correct
6 Correct 20 ms 3264 KB Output is correct
7 Correct 20 ms 3272 KB Output is correct
8 Correct 52 ms 6936 KB Output is correct
9 Incorrect 80 ms 11980 KB Output isn't correct
10 Incorrect 72 ms 11980 KB Output isn't correct