답안 #376257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376257 2021-03-11T06:18:27 Z dantoh000 Odašiljači (COCI20_odasiljaci) C++14
0 / 70
62 ms 8664 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> iii;
int n;
int x[1005], y[1005];
vector<iii> edg;
int p[1005];
int rk[1005];
int nume = 0;
void init(int n){
    for (int i = 0; i < n; i++){
        p[i] = i;
        rk[i] = 0;
    }
}
int find(int x){
    return p[x] == x?  x : p[x] = find(p[x]);
}
void un(int x, int y){
    x = find(x) ,y = find(y);
    if (x == y) return;
    nume ++;
    if (rk[x] < rk[y]) swap(x,y);
    p[y] = x;
    if (rk[x] == rk[y]) rk[x]++;
}
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d%d",&x[i],&y[i]);
    }
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            edg.emplace_back((ll)(y[i]-y[j])*(y[i]-y[j]) + (ll)(x[i]-x[j])*(x[i]-x[j]),i,j);
        }
    }
    init(n);
    sort(edg.begin(),edg.end());
    ll ans = 0;
    for (auto e : edg){
        ll d;
        int x,y;
        tie(d,x,y) = e;
        ans = d;
        un(x,y);
        //printf("%lld %d %d\n",d,x,y);
        if (nume == n-1) break;
    }
    printf("%.9lf\n",pow((long double)ans, 0.5)/2);
}

Compilation message

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:50:17: warning: format '%lf' expects argument of type 'double', but argument 2 has type '__gnu_cxx::__promote_2<long double, double, long double, double>::__type' {aka 'long double'} [-Wformat=]
   50 |     printf("%.9lf\n",pow((long double)ans, 0.5)/2);
      |             ~~~~^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 |                              |
      |                 double                         __gnu_cxx::__promote_2<long double, double, long double, double>::__type {aka long double}
      |             %.9Lf
odasiljaci.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
odasiljaci.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         scanf("%d%d",&x[i],&y[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Incorrect 1 ms 492 KB Output isn't correct
5 Incorrect 1 ms 492 KB Output isn't correct
6 Incorrect 18 ms 2528 KB Output isn't correct
7 Incorrect 17 ms 2528 KB Output isn't correct
8 Incorrect 51 ms 8664 KB Output isn't correct
9 Incorrect 62 ms 8664 KB Output isn't correct
10 Incorrect 62 ms 8664 KB Output isn't correct