답안 #474150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
474150 2021-09-17T02:55:28 Z LeeRise Odašiljači (COCI20_odasiljaci) C++14
0 / 70
3 ms 392 KB
#include<bits/stdc++.h>
#define fast(); ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld double
using namespace std;
ll n, N=1005, oo=1e9;
ld l=0,r=2*oo,kq=2*oo;
struct Point
{
	ll x, y;
	ld dd(Point a)
	{
		return sqrt((x - a.x) * (x - a.x) + (y - a.y) * (y - a.y));
	}
};
bool check(vector<vector<int>> &g)
{
	queue<int> q;
	vector<bool> v(1001, 0);
	q.push(0);
	v[0] = 1;
	while(!q.empty())
    {
		int x = q.front();
		q.pop();
		for(int u: g[x])
		{
			if(!v[u])
			{
				v[u] = 1;
				q.push(u);
			}
		}
	}
	bool ok=1;
	for(int i=0;i<n;i++) ok&=v[i];
	return ok;
}

int main()
{
    Point a[N];
    fast();
    freopen ("odasiljaci.inp", "r", stdin);
    freopen ("odasiljaci.out", "w", stdout);
	cin >> n;
	for(int i=0;i<n;i++) cin>>a[i].x>>a[i].y;
	while(l + (0.000001f) < r)
    {
		ld giua = (l+r)/2.0;
		vector<vector<int>> g(N);
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				ld d = a[i].dd(a[j]);
				if(d <= giua){
					g[i].push_back(j);
					g[j].push_back(i);
				}
			}
		}
        if(check(g))
            {
                kq=min(kq, giua);
                r=giua;
            }
        else l=giua;
	}
	cout<<fixed<<setprecision(7);
	cout<<l/2.0;
}

Compilation message

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:44:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     freopen ("odasiljaci.inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
odasiljaci.cpp:45:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     freopen ("odasiljaci.out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Unexpected end of file - double expected
2 Incorrect 3 ms 392 KB Unexpected end of file - double expected
3 Incorrect 2 ms 332 KB Unexpected end of file - double expected
4 Incorrect 2 ms 332 KB Unexpected end of file - double expected
5 Incorrect 2 ms 332 KB Unexpected end of file - double expected
6 Incorrect 3 ms 332 KB Unexpected end of file - double expected
7 Incorrect 2 ms 332 KB Unexpected end of file - double expected
8 Incorrect 2 ms 332 KB Unexpected end of file - double expected
9 Incorrect 3 ms 332 KB Unexpected end of file - double expected
10 Incorrect 2 ms 332 KB Unexpected end of file - double expected