답안 #346469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
346469 2021-01-09T20:37:13 Z Nursik Odašiljači (COCI20_odasiljaci) C++14
42 / 70
1000 ms 4588 KB
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end() 
#define ld long double
#define fi first
#define se second
 
using namespace std; 
 
void data() {
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif	
} 
void win()
{	
	ios_base::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
}
 
int block = 400;
const ld eps = 1e-9; 
 
const int N = 1e6 + 500;
const int mod = 1e9 + 7;
 
const ll hh = 100010683;
const ll hh2 = 150005819;
 
int n, x[2000], y[2000], was[2000];
vector<int> g[2000];
void dfs(int v)
{
	if (was[v])
		return;
	was[v] = 1;
	for (int i = 0; i < g[v].size(); i++)
	{
		int to = g[v][i];
		dfs(to);
	}
}
bool check(ld xe)
{
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if ((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= (xe + xe) * (xe + xe))
			{
				g[i].pb(j);
				g[j].pb(i);
			}
		}
	} 
	dfs(1);
	for (int i = 1; i <= n; i++)
	{
		if (!was[i])
			return 0;
	}
	return 1;
}
main()
{
	data();              
	win();        	
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x[i] >> y[i];
	}
	ld l = 0, r = 1e16, ans;
	for (int i = 1; i <= 300; i++)
	{
		ld mid = (l + r) / 2.0;
		if (check(mid))
		{
			r = mid - eps;
			ans = mid;
		}
		else
		{
			l = mid + eps;
		}
		for (int i = 1; i <= n; i++)
		{
			was[i] = 0;
			g[i].clear();
		}
	}
	cout << fixed << setprecision(7) << r;
}
/*
Если я солью, то я обязательно затащю
*/

Compilation message

odasiljaci.cpp: In function 'void dfs(int)':
odasiljaci.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int i = 0; i < g[v].size(); i++)
      |                  ~~^~~~~~~~~~~~~
odasiljaci.cpp: At global scope:
odasiljaci.cpp:69:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      |      ^
odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:78:22: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   78 |  ld l = 0, r = 1e16, ans;
      |                      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Incorrect 11 ms 492 KB Output isn't correct
5 Incorrect 20 ms 492 KB Output isn't correct
6 Correct 249 ms 1388 KB Output is correct
7 Correct 262 ms 1388 KB Output is correct
8 Correct 560 ms 3436 KB Output is correct
9 Execution timed out 1045 ms 4460 KB Time limit exceeded
10 Execution timed out 1094 ms 4588 KB Time limit exceeded