QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#818244#9860. Light of StarsSGColinWA 7ms6224kbC++202.6kb2024-12-17 17:54:102024-12-17 17:54:13

Judging History

This is the latest submission verdict.

  • [2024-12-17 17:54:13]
  • Judged
  • Verdict: WA
  • Time: 7ms
  • Memory: 6224kb
  • [2024-12-17 17:54:10]
  • Submitted

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, cnt = 0;
			for (auto [x, y, id] : pts) {
				if (x != lstx) lstx = x, cnt = 0;
				else ans[id] += cnt; 
				++cnt;
			}
			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; cnt = 0;
		for (auto [x, y, id] : pts) {
			if (x != lstx) lstx = x, cnt = 0;
			else ans[id] += cnt; 
			++cnt;
		}
		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) {
		ans[id] += bit.sum(y);
		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: 0ms
memory: 6224kb

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: 0
Accepted
time: 7ms
memory: 4592kb

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:

98 404 1262 451 362 65 248 860 967 2062 849 2054 756 1078 117 2352 1550 116 887 1495 181 217 1140 1236 1266 1326 2110 1226 1473 132 1363 1875 1660 762 582 916 1761 1000 1670 83 1652 1254 1181 755 1739 969 1219 1578 602 4 16 46 948 966 11 167 792 692 2037 1714 2259 1957 797 1584 2151 513 1608 41 1889...

result:

ok single line: '98 404 1262 451 362 65 248 860...036 1166 117 1290 2616 400 214 '

Test #3:

score: 0
Accepted
time: 7ms
memory: 4564kb

input:

3000 10
25116 28527
12269 47809
41407 49789
6250 3129
10917 15869
16391 45424
19848 44903
36350 7694
31 13717
2532 20408
19540 15613
18692 16331
5082 6823
25042 37243
46127 17531
18955 37376
33321 4339
39970 23142
33262 6099
28338 34417
37272 4454
16932 36602
22205 28996
348 42442
24696 9172
35526 9...

output:

912 26 1 1723 1264 86 110 2202 1047 858 1500 1407 1469 503 1778 421 2322 1345 2235 669 2391 442 902 52 1898 2075 1412 1478 2277 866 1673 1703 1154 1466 522 1853 259 1211 1610 70 1882 1010 417 205 2430 34 219 134 278 425 1962 22 723 923 977 552 1271 385 2794 383 1300 2249 1349 759 149 1199 2591 208 1...

result:

ok single line: '912 26 1 1723 1264 86 110 2202...775 1314 1814 1288 925 450 283 '

Test #4:

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

input:

3000 10
38028 49299
17481 33121
20563 46270
43617 24889
22547 30215
39933 36027
12834 46469
16900 124
32632 32321
19648 47208
33823 7908
13175 25831
13693 38900
29458 11824
21804 39002
13338 19226
19779 11998
3750 6413
32633 24008
19004 34739
5766 26111
41304 3331
44596 46238
33998 7444
22938 47560
...

output:

4 102 36 392 168 193 20 195 194 21 544 91 58 414 82 117 206 9 310 100 14 719 60 538 26 115 223 28 101 106 254 112 780 717 30 545 337 40 313 211 143 219 593 1 789 698 8 1 56 461 36 86 51 898 27 184 1 1 284 95 493 36 298 805 4 609 125 3 716 479 174 166 500 124 336 123 414 470 91 100 3 509 116 562 127 ...

result:

wrong answer 1st lines differ - expected: '4 102 36 392 168 193 20 195 19... 588 511 634 61 214 514 455 188', found: '4 102 36 392 168 193 20 195 19...588 511 634 61 214 514 455 188 '