QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801973#9869. Horizon Scanningucup-team5657#WA 222ms10428kbC++203.2kb2024-12-07 11:05:572024-12-07 11:05:58

Judging History

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

  • [2024-12-07 11:05:58]
  • 评测
  • 测评结果:WA
  • 用时:222ms
  • 内存:10428kb
  • [2024-12-07 11:05:57]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) / 2)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;

namespace FastIO {
char buf[1 << 23], *p1 = buf, *p2 = buf;
inline char gc(void) {
	if(p1 == p2 && (p1 = buf, p2 = buf + fread(buf, 1, 1 << 23, stdin), p1 == p2)) return EOF;
	return *p1++;
}
int in(void) {
	int x = 0, c = gc(), f = 1; while(!isdigit(c)) { if(c == '-') f = -1; c = gc(); }
	while(isdigit(c)) x = x * 10 + c - '0', c = gc();
	return x * f;
}
ll inl(void) {
	ll x = 0; int c = gc(), f = 1; while(!isdigit(c)) { if(c == '-') f = -1; c = gc(); }
	while(isdigit(c)) x = x * 10 + c - '0', c = gc();
	return x * f;
}
char obuf[1 << 23], *p3 = obuf;
inline void pc(char c) { *p3++ = c; if(p3 == obuf + (1 << 23)) fwrite(obuf, 1, 1 << 23, stdout), p3 = obuf; }
template<typename T> void out_(T x) { if(x > 9) out_(x / 10); pc(x % 10 + '0'); }
template<typename T> void out(T x) { if(x < 0) pc('-'), x = -x; out_(x); pc(' '); }
template<typename T> void outln(T x) { if(x < 0) pc('-'), x = -x; out_(x); pc('\n'); } 
struct FLUSHer { ~FLUSHer() { fwrite(obuf, 1, p3 - obuf, stdout); } } flusher;
} using FastIO::in; using FastIO::inl; using FastIO::out; using FastIO::outln;
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); } 
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); } 
const int kN = 205000;
const double eps = 1e-8, pi = acos(-1);
int n, k;
double A[kN];
int tag[kN << 1];
int main() {
	multiCase() {
		n = in(), k = in();
		_rep(i,1,n) {
			int x = in(), y = in();
			A[i] = atan2(y, x);
		}
		sort(A + 1, A + 1 + n);
		double L = 0, R = pi, ans = 0;
		while(R - L > eps) {
			vector<double> a1, ra1, a2, ra2;
			_rep(i,1,n) {
				if(A[i] - mid >= -pi) a1.emplace_back(A[i] - mid);
				else ra1.emplace_back(pi - (-pi - (A[i] - mid)));
				if(A[i] + mid <= pi) a2.emplace_back(A[i] + mid);
				else ra2.emplace_back(-pi + (A[i] + mid - pi));
			}
			reverse(ra1.begin(), ra1.end());
			a1.insert(a1.end(), ra1.begin(), ra1.end()); 
		 	ra2.emplace_back(-pi); reverse(ra2.begin(), ra2.end());
			ra2.insert(ra2.end(), a2.begin(), a2.end()); ra2.emplace_back(pi);
			vector<double> d(a1.size() + ra2.size());
			merge(a1.begin(), a1.end(), ra2.begin(), ra2.end(), d.begin());
			d.erase(unique(d.begin(), d.end()), d.end());
			auto locate = [&](double x) { return lower_bound(d.begin(), d.end(), x) - d.begin(); };
			int mn = n, cur = 0;
			_rep(i,1,n) {
				if(A[i] - mid >= -pi) tag[locate(A[i] - mid)]++;
				else tag[0]++, tag[locate(pi - (-pi - (A[i] - mid)))]++;
				if(A[i] + mid <= pi) tag[locate(A[i] + mid)]--;
				else tag[0]++, tag[locate(-pi + (A[i] + mid - pi))]--;
			}
			int m = d.size();
			_rep(i,0,m - 2) {
				cur += tag[i]; chkmin(mn, cur);
			}
			_rep(i,0,m) tag[i] = 0;
			if(mn >= k) R = mid; else L = mid;
		}
		printf("%.10lf\n", L * 2);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 10416kb

input:

5
1 1
0 1
8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1
4 2
-1 1
0 1
0 2
1 1
4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0
3 1
0 1
0 2
0 -1

output:

6.2831852955
1.5707963151
5.4977871438
3.1415926536
3.1415926419

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 222ms
memory: 10428kb

input:

10000
16 1
-10 -6
-5 -6
-4 9
-2 5
-2 10
1 -7
1 -5
1 6
3 1
4 -9
6 -10
6 -3
6 1
8 -5
8 -4
9 -4
17 4
-9 2
-8 -4
-8 -3
-8 -1
-6 -2
-6 -1
-6 8
-5 -8
-5 10
-4 8
-2 -8
4 -9
4 0
5 -3
8 -5
9 -2
10 10
10 6
-7 2
-4 6
-2 -7
-2 -1
-1 7
1 -9
1 8
3 -4
7 -4
9 -2
14 3
-9 10
-8 -10
-8 -8
-6 -7
-6 -5
-1 -7
-1 -2
0 -1
...

output:

1.6929914865
2.5748634328
4.6527582627
2.7726331043
5.4977871321
4.6314848707
3.3865713118
2.8127999544
6.2831852955
6.2831852955
4.8230461988
6.1467826967
3.8420890204
2.3424967084
3.4633432045
6.2831852955
5.9614347446
3.3247034646
4.9337034172
5.6724593401
1.4940244341
1.1141908508
2.2455372601
6...

result:

wrong answer 5th numbers differ - expected: '5.7427658', found: '5.4977871', error = '0.0426587'