답안 #376252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376252 2021-03-11T06:10:09 Z tqbfjotld Odašiljači (COCI20_odasiljaci) C++14
70 / 70
128 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;}

long long X[1005];
long long 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:33:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   33 |         scanf("%d%d",&X[x],&Y[x]);
      |                ~^    ~~~~~
      |                 |    |
      |                 int* long long int*
      |                %lld
odasiljaci.cpp:33:19: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   33 |         scanf("%d%d",&X[x],&Y[x]);
      |                  ~^        ~~~~~
      |                   |        |
      |                   int*     long long int*
      |                  %lld
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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 54 ms 492 KB Output is correct
7 Correct 52 ms 364 KB Output is correct
8 Correct 115 ms 364 KB Output is correct
9 Correct 128 ms 412 KB Output is correct
10 Correct 75 ms 492 KB Output is correct