Submission #376251

# Submission time Handle Problem Language Result Execution time Memory
376251 2021-03-11T06:08:49 Z tqbfjotld Odašiljači (COCI20_odasiljaci) C++14
42 / 70
280 ms 492 KB
#include <bits/stdc++.h>
using namespace std;

int p[1005];
int rt(int a){return p[a]==a?a:p[a]=rt(p[a]);}
void un(int a, int b){a = rt(a); b = rt(b); p[a] = b;}

int X[1005];
int Y[1005];
int n;

bool check(long long a){
    for (int x = 0; x<n; x++){
        p[x] = x;
    }
    for (int x = 0; x<n; x++){
        for (int y = x+1; y<n; y++){
            if (((X[x]-X[y])*(X[x]-X[y]))+((Y[x]-Y[y])*(Y[x]-Y[y]))<=a){
                un(x,y);
            }
        }
    }
    int t = rt(0);
    for (int x = 1; x<n; x++){
        if (rt(x)!=t) return false;
    }
    return true;
}

int main(){
    scanf("%d",&n);
    for (int x = 0; x<n; x++){
        scanf("%d%d",&X[x],&Y[x]);
    }
    long long a = -1;
    long long b = 2000000000000000000;
    while (a+1<b){
        long long mid = (a+b)/2;
        if (check(mid)){
            b = mid;
        }
        else a = mid;
    }
    printf("%f",sqrt((double)b)/2);
}

Compilation message

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
odasiljaci.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |         scanf("%d%d",&X[x],&Y[x]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 5 ms 364 KB Output isn't correct
5 Incorrect 10 ms 364 KB Output isn't correct
6 Correct 115 ms 492 KB Output is correct
7 Correct 54 ms 492 KB Output is correct
8 Correct 116 ms 364 KB Output is correct
9 Incorrect 277 ms 492 KB Output isn't correct
10 Incorrect 280 ms 492 KB Output isn't correct