QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390407#5803. Watering Plantscmk66630 ✓2244ms4052kbC++238.2kb2024-04-15 15:09:182024-04-15 15:09:18

Judging History

你现在查看的是最新测评结果

  • [2024-04-15 15:09:18]
  • 评测
  • 测评结果:30
  • 用时:2244ms
  • 内存:4052kb
  • [2024-04-15 15:09:18]
  • 提交

answer

/*  _              _     _                                             _       __      __      __   
   / \     _   _  | |_  | |__     ___    _ __   _    ___   _ __ ___   | | __  / /_    / /_    / /_  
  / _ \   | | | | | __| | '_ \   / _ \  | '__| (_)  / __| | '_ ` _ \  | |/ / | '_ \  | '_ \  | '_ \ 
 / ___ \  | |_| | | |_  | | | | | (_) | | |     _  | (__  | | | | | | |   <  | (_) | | (_) | | (_) |
/_/   \_\  \__,_|  \__| |_| |_|  \___/  |_|    (_)  \___| |_| |_| |_| |_|\_\  \___/   \___/   \___/ 
[Created Time:       2024-04-15 14:23:53]
[Last Modified Time: 2024-04-15 15:09:12] */
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#ifdef LOCAL
#include"debug.h"
#else
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
// ------------------------------
// #define DISABLE_MMAP
// ------------------------------
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifdef LOCAL
	inline char gc() { return getchar(); }
	inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
	inline constexpr int _READ_SIZE = 1 << 18;
	inline static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
	inline char gc()
	{
		if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
		{
			_read_ptr = _read_buffer, _read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
			if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
		}
		return *_read_ptr++;
	}
#else
#include<sys/mman.h>
	inline static const char *_read_ptr = (const char *)mmap(nullptr, 0x7fffffff, 1, 2, 0, 0);
	inline char gc() { return *_read_ptr++; }
#endif
	inline constexpr int _WRITE_SIZE = 1 << 18;
	inline static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
	inline void pc(char c)
	{
		*_write_ptr++ = c;
		if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
			fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout), _write_ptr = _write_buffer;
	}
	inline struct _auto_flush
	{
		inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
	}	_auto_flush;
#endif
	template < class T > inline constexpr bool _is_signed = numeric_limits < T >::is_signed;
	template < class T > inline constexpr bool _is_unsigned = numeric_limits < T >::is_integer && !_is_signed < T >;
#if __SIZEOF_LONG__ == 64
	template <> inline constexpr bool _is_signed < __int128 > = true;
	template <> inline constexpr bool _is_unsigned < __uint128_t > = true;
#endif
	inline void read(char &c) { do c = gc(); while ( !isgraph(c) ); }
	inline void read_cstr(char *s)
	{
		char c = gc(); while ( !isgraph(c) ) c = gc();
		while ( isgraph(c) ) *s++ = c, c = gc(); *s = 0;
	}
	inline void read(string &s)
	{
		char c = gc(); s.clear(); while ( !isgraph(c) ) c = gc();
		while ( isgraph(c) ) s.push_back(c), c = gc();
	}
	template < class T, enable_if_t < _is_signed < T >, int > = 0 >
	inline void read(T &x)
	{
		char c = gc(); bool f = true; x = 0;
		while ( !isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
		if ( f ) while ( isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
		else     while ( isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
	}
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
	inline void read(T &x)
	{
		char c = gc(); while ( !isdigit(c) ) c = gc();
		x = 0; while ( isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
	}
	inline void write(char c) { pc(c); }
	inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
	inline void write(const string &s) { for ( char c : s ) pc(c); }
	template < class T, enable_if_t < _is_signed < T >, int > = 0 >
	inline void write(T x)
	{
		char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
		if ( x >= 0 )  do buffer[digits++] =  ( x % 10 ) | 48, x /= 10; while ( x );
		else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
		while ( digits ) pc(buffer[--digits]);
	}
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
	inline void write(T x)
	{
		char buffer[numeric_limits < T >::digits10]; int digits = 0;
		do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
		while ( digits ) pc(buffer[--digits]);
	}
	template < int N > struct _tuple_io_helper
	{
		template < class ...T > static inline void _read(tuple < T... > &x) { _tuple_io_helper < N - 1 >::_read(x), read(get<N - 1>(x)); }
		template < class ...T > static inline void _write(const tuple < T... > &x) { _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get<N - 1>(x)); }
	};
	template <> struct _tuple_io_helper < 1 >
	{
		template < class ...T > static inline void _read(tuple < T... > &x) { read(get<0>(x)); }
		template < class ...T > static inline void _write(const tuple < T... > &x) { write(get<0>(x)); }
	};
	template < class ...T > inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
	template < class ...T > inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
	template < class T1, class T2 > inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
	template < class T1, class T2 > inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
	template < class T1, class ...T2 > inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
	template < class ...T > inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
	template < class T1, class ...T2 > inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
	template < class ...T > inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
	template < class T > inline void print(const T &x) { write(x); }
	inline void print_cstr(const char *x) { write_cstr(x); }
	template < class T1, class ...T2 > inline void print(const T1 &x, const T2 &...y) { write(x), pc(32), print(y...); }
	template < class ...T > inline void print_cstr(const char *x, const T *...y) { write_cstr(x), pc(32), print_cstr(y...); }
	inline void println() { pc(10); } inline void println_cstr() { pc(10); }
	template < class ...T > inline void println(const T &...x) { print(x...), pc(10); }
	template < class ...T > inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}	using FastIO::read, FastIO::read_cstr, FastIO::write, FastIO::write_cstr, FastIO::println, FastIO::println_cstr;
using ld = long double; constexpr ld eps = 1e-10l;
inline int cmp(ld x, ld y) { return fabsl(x - y) < eps ? 0 : x < y ? -1 : 1; }
int n, x, y, r[49], cnt; ll al, bs[1609]; ld l_, r_, md_, d, t, a;
struct P { ld x, y; inline P() {} inline P(ld x, ld y) : x(x), y(y) {} } p[1609];
struct C { P o; ld r; inline C() {} inline C(const P &o, ld r) : o(o), r(r) {} } c[49];
inline ld dis(const P &x, const P &y) { return hypotl(x.x - y.x, x.y - y.y); }
inline bool chk(ld ad)
{
	cnt = n;
	For(i, 1, n) c[i] = C(p[i], ad - r[i]);
	For(i, 1, n) For(j, i + 1, n)
	{
		d = dis(c[i].o, c[j].o);
		if ( cmp(d, c[i].r + c[j].r) > 0 || cmp(d, fabsl(c[i].r - c[j].r)) < 0 ) continue;
		a = atan2l(c[j].o.y - c[i].o.y, c[j].o.x - c[i].o.x),
		t = acosl(( d * d + c[i].r * c[i].r - c[j].r * c[j].r ) / 2 / d / c[i].r),
		p[++cnt] = P(c[i].o.x + c[i].r * cosl(a + t), c[i].o.y + c[i].r * sinl(a + t)),
		p[++cnt] = P(c[i].o.x + c[i].r * cosl(a - t), c[i].o.y + c[i].r * sinl(a - t));
	}
	For(i, 1, cnt)
	{
		bs[i] = 0;
		For(j, 1, n) if ( cmp(dis(p[i], c[j].o), c[j].r) < 1 ) bs[i] |= 1ll << j;
		if ( bs[i] == al ) return true;
		For(j, 1, i - 1) if ( ( bs[i] | bs[j] ) == al ) return true;
	}
	return false;
}
inline void work()
{
	static int _; cout << "Case #" << ++_ << ": ";
	read(n), al = 0, l_ = 1e3;
	For(i, 1, n) read(x, y, r[i]), p[i] = P(x, y), al |= 1ll << i, l_ = min(l_, (ld)r[i]);
	for ( r_ = 1e3 ; r_ - l_ > eps ; ) chk(md_ = ( l_ + r_ ) / 2) ? r_ = md_: l_ = md_;
	cout << fixed << setprecision(9) << ( l_ + r_ ) / 2 << '\n';
}
int main() { int t; read(t); For(tt, 1, t) work(); return 0; }
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 3968kb

input:

10
3
20 10 2
20 20 2
40 10 3
3
20 10 3
30 10 3
40 10 3
1
964 880 60
2
68 982 51
698 947 76
2
495 946 38
336 41 21
3
509 182 47
86 849 73
331 148 62
3
135 5 22
860 80 51
229 43 30
3
588 110 12
890 159 10
566 654 7
3
603 989 47
76 850 28
522 287 29
3
494 969 76
807 103 32
981 315 12

output:

Case #1: 7.000000000
Case #2: 8.000000000
Case #3: 60.000000000
Case #4: 76.000000000
Case #5: 38.000000000
Case #6: 145.109050321
Case #7: 76.695167423
Case #8: 163.974671106
Case #9: 310.011467649
Case #10: 159.131323920

result:

ok correct! (10 test cases)

Subtask #2:

score: 25
Accepted

Test #2:

score: 25
Accepted
time: 2244ms
memory: 4052kb

input:

30
5
100 100 1
140 100 1
100 130 1
100 500 1
150 500 1
8
100 100 1
110 100 1
100 110 1
110 110 1
200 200 1
210 200 1
200 210 1
210 210 1
4
100 100 1
200 100 1
200 103 1
300 103 1
40
138 129 1
110 145 1
820 565 1
813 556 1
820 535 1
824 567 1
840 565 1
840 535 1
130 145 1
829 532 1
847 556 1
812 551 ...

output:

Case #1: 26.000000000
Case #2: 8.071067812
Case #3: 51.000000000
Case #4: 19.027756377
Case #5: 529.843413543
Case #6: 511.486079962
Case #7: 565.633650138
Case #8: 517.076068593
Case #9: 525.384009689
Case #10: 534.528692005
Case #11: 543.733191669
Case #12: 216.939237343
Case #13: 197.863908830
Ca...

result:

ok correct! (30 test cases)

Extra Test:

score: 0
Extra Test Passed