QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#818237#9860. Light of StarsSGColinWA 7ms4632kbC++202.6kb2024-12-17 17:51:292024-12-17 17:51:30

Judging History

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

  • [2024-12-17 17:51:30]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:4632kb
  • [2024-12-17 17:51:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tii;

#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

inline int rd() {
	int x = 0;
	bool f = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) f |= (c == '-');
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	return f ? -x : x;
}

constexpr int N = 100007;
constexpr double eps = 1e-10;
constexpr double PI = 3.1415926535897932384626433832795;

int n, q, ans[N], X[N], Y[N], x[N], y[N];

struct BIT {
	int c[N];
	inline void clear() {memset(c, 0, sizeof(c));}
	inline int lowbit(int x) {return x & (-x);}
	inline void add(int x) {
		for (; x < N; x += lowbit(x)) ++c[x];
	}
	inline int sum(int x) {
		int ret = 0;
		for (; x; x -= lowbit(x)) ret += c[x];
		return ret;
	}
} bit;

inline void work() {
	int l = rd(), r = rd();
	double a = cos(r * PI / 180);
	double b = -sin(r * PI / 180);
	double c = cos(l * PI / 180);
	double d = -sin(l * PI / 180);

	vector<tii> pts;
	vector<pair<double, int>> tmp;
	if (l == r) {
		if (l == 90) {
			rep(i, 1, n) pts.eb(X[i], Y[i], i);
			sort(all(pts));
			reverse(all(pts));
			int lstx = -1e9;
			for (auto [x, y, id] : pts) {
				if (x != lstx) {lstx = x; continue;}
				++ans[id];
			}
			return;
		}
		rep(i, 1, n) tmp.eb(Y[i] - b * X[i] / a, i);
		sort(all(tmp)); 
		double lst = -1e18;
		int cnt = 0;
		for (auto [w, id] : tmp) {
			if (abs(w - lst) > eps) ++cnt;
			x[id] = cnt;
			lst = w;
		}
		rep(i, 1, n) pts.eb(x[i], Y[i], i);
		sort(all(pts));
		reverse(all(pts));
		int lstx = -1e9;
		for (auto [x, y, id] : pts) {
			if (x != lstx) {lstx = x; continue;}
			++ans[id];
		}
		return;
	}
	
	rep(i, 1, n) tmp.eb((c * Y[i] - d * X[i]) / (b * c - a * d), i);
	sort(all(tmp)); 
	double lst = -1e18;
	int cnt = 0;
	for (auto [w, id] : tmp) {
		if (abs(w - lst) > eps) ++cnt;
		x[id] = cnt;
		lst = w;
	}
	tmp.clear();
	rep(i, 1, n) tmp.eb((a * Y[i] - b * X[i]) / (a * d - b * c), i);
	sort(all(tmp)); 
	lst = -1e18;
	cnt = 0;
	for (auto [w, id] : tmp) {
		if (abs(w - lst) > eps) ++cnt;
		y[id] = cnt;
		lst = w;
	}
	rep(i, 1, n) pts.eb(x[i], y[i], i);
	sort(all(pts));

	bit.clear();
	for (auto [x, y, id] : pts) {
		if (bit.sum(y)) ++ans[id];
		bit.add(y);
	}
}

int main() {
	n = rd(), q = rd();
	rep(i, 1, n) X[i] = rd(), Y[i] = rd();
	rep(i, 1, q) work();
	rep(i, 1, n) printf("%d ", ans[i]);
	return 0;
}

詳細信息

Test #1:

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

input:

4 2
0 0
4 5
2 4
1 5
0 45
120 150

output:

1 1 1 0 

result:

ok single line: '1 1 1 0 '

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 4564kb

input:

3000 10
44972 48171
30241 41392
24297 21452
42706 42506
19480 39475
8769 45623
47439 45915
17463 26926
14966 24009
21288 3192
599 17221
18111 1118
20153 30842
37473 29893
20947 46060
36233 5528
28751 17812
23199 46350
24068 29630
22664 16335
19304 43933
42559 46163
2279 11754
12826 16304
32165 24656...

output:

2 9 10 9 10 9 3 10 10 10 10 10 10 10 7 10 10 5 10 10 9 8 10 10 10 10 5 10 10 10 10 10 10 4 10 9 10 10 10 7 10 10 10 10 10 10 10 10 10 1 2 5 10 10 1 9 10 1 6 10 10 10 10 10 8 10 10 10 10 10 10 10 10 10 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 6 10 10 2 10 10 1 1 10 9 10 10 10 10 10 10 7 1...

result:

wrong answer 1st lines differ - expected: '98 404 1262 451 362 65 248 860...1036 1166 117 1290 2616 400 214', found: '2 9 10 9 10 9 3 10 10 10 10 10... 10 10 9 7 10 10 8 10 10 10 10 '