답안 #415076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
415076 2021-05-31T13:50:56 Z hhhhaura 원 고르기 (APIO18_circle_selection) C++14
100 / 100
2576 ms 88204 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define INF 1e9
#define int long long int
#define pii pair<int, int>
using namespace std;
#define x first
#define y second
namespace solver {
	int n, r, c, w, ii;
	vector<unordered_set<int>> v;
	vector<pii> a;
	vector<int> vis, ord, rad;
	unordered_map<int, int> mp;
	void init_(int _n) {
		n = _n;
		a.assign(n + 1, {0, 0});
		rad.assign(n + 1, 0);
		vis.assign(n + 1, 0);
		ord.clear();
		mp.clear();
		rep(i, 1, n) ord.push_back(i);
	}
	bool cmp(int a, int b) {
		if(rad[a] != rad[b]) 
			return rad[a] > rad[b];
		else return a < b;
	}
	int get_id(pii a) {
		int xx = (a.x + INF)/ w;
		int yy = (a.y + INF)/ w;
		return xx * c + yy;
	}
	void reconstruct(int x) {
		w = x, ii = 0;
		r = ceil(2 * INF, w);
		c = ceil(2 * INF, w);
		v.assign(n + 1, unordered_set<int>());
		mp.clear();
		rep(i, 1, n) if(!vis[i]) {
			pii cur = a[i]; int id = get_id(cur);
			if(mp.find(id) == mp.end()) mp[id] = ++ii;
			v[mp[id]].insert(i);
		}
	}
	int dis2(pii a, pii b) {
		return (a.x - b.x) * (a.x - b.x) + 
			(a.y - b.y) * (a.y - b.y); 
	}
	void operate(int id, int x) {
		rep(xx, -2, 2) rep(yy, -2, 2) {
			int i = xx * c + id + yy;
			if(mp.find(i) == mp.end()) continue;
			int bk = mp[i];
			auto it = v[bk].begin();
			while(it != v[bk].end()) {
				if(dis2(a[*it], a[x]) <= 
					(rad[*it] + rad[x]) * (rad[*it] + rad[x])) {
					vis[*it] = x; 
					auto cur = it;  
					it = next(cur), v[bk].erase(cur);
				}
				else it = next(it);
			}	
		}
		return;
	}
	void solve() {
		sort(all(ord), cmp);
		reconstruct(rad[ord[0]]);
		for(auto i : ord) if(!vis[i]) { 
			if(rad[i] * 2 <= w) reconstruct(rad[i]);
			int id = get_id(a[i]); operate(id, i);
		}
		rep(i, 1, n) cout << vis[i] << " \n"[i == n]; 
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n;
	init_(n);
	rep(i, 1, n) {
		cin >> a[i].x >> a[i].y;
		cin >> rad[i];
	}
	solve();
	return 0;
}

Compilation message

circle_selection.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 5 ms 972 KB Output is correct
20 Correct 5 ms 972 KB Output is correct
21 Correct 6 ms 972 KB Output is correct
22 Correct 13 ms 1668 KB Output is correct
23 Correct 16 ms 1708 KB Output is correct
24 Correct 13 ms 1612 KB Output is correct
25 Correct 12 ms 1720 KB Output is correct
26 Correct 13 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 43684 KB Output is correct
2 Correct 427 ms 43244 KB Output is correct
3 Correct 309 ms 44308 KB Output is correct
4 Correct 303 ms 42832 KB Output is correct
5 Correct 489 ms 44412 KB Output is correct
6 Correct 926 ms 63052 KB Output is correct
7 Correct 481 ms 45484 KB Output is correct
8 Correct 814 ms 47704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 435 ms 28880 KB Output is correct
3 Correct 1805 ms 85892 KB Output is correct
4 Correct 2029 ms 86676 KB Output is correct
5 Correct 1740 ms 77852 KB Output is correct
6 Correct 678 ms 40396 KB Output is correct
7 Correct 285 ms 21660 KB Output is correct
8 Correct 28 ms 5064 KB Output is correct
9 Correct 2250 ms 85588 KB Output is correct
10 Correct 1261 ms 76432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1509 ms 85904 KB Output is correct
2 Correct 1311 ms 85916 KB Output is correct
3 Correct 700 ms 52952 KB Output is correct
4 Correct 1683 ms 88152 KB Output is correct
5 Correct 1381 ms 88204 KB Output is correct
6 Correct 536 ms 46860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 5 ms 972 KB Output is correct
20 Correct 5 ms 972 KB Output is correct
21 Correct 6 ms 972 KB Output is correct
22 Correct 13 ms 1668 KB Output is correct
23 Correct 16 ms 1708 KB Output is correct
24 Correct 13 ms 1612 KB Output is correct
25 Correct 12 ms 1720 KB Output is correct
26 Correct 13 ms 1612 KB Output is correct
27 Correct 11 ms 1612 KB Output is correct
28 Correct 9 ms 1760 KB Output is correct
29 Correct 9 ms 1744 KB Output is correct
30 Correct 26 ms 3072 KB Output is correct
31 Correct 24 ms 3072 KB Output is correct
32 Correct 25 ms 3020 KB Output is correct
33 Correct 85 ms 15912 KB Output is correct
34 Correct 102 ms 15444 KB Output is correct
35 Correct 112 ms 15680 KB Output is correct
36 Correct 425 ms 29932 KB Output is correct
37 Correct 433 ms 29980 KB Output is correct
38 Correct 404 ms 29876 KB Output is correct
39 Correct 574 ms 27824 KB Output is correct
40 Correct 620 ms 27864 KB Output is correct
41 Correct 619 ms 27868 KB Output is correct
42 Correct 320 ms 29792 KB Output is correct
43 Correct 329 ms 29596 KB Output is correct
44 Correct 288 ms 29588 KB Output is correct
45 Correct 409 ms 29600 KB Output is correct
46 Correct 315 ms 29572 KB Output is correct
47 Correct 386 ms 29636 KB Output is correct
48 Correct 333 ms 29572 KB Output is correct
49 Correct 323 ms 29568 KB Output is correct
50 Correct 294 ms 29604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 5 ms 972 KB Output is correct
20 Correct 5 ms 972 KB Output is correct
21 Correct 6 ms 972 KB Output is correct
22 Correct 13 ms 1668 KB Output is correct
23 Correct 16 ms 1708 KB Output is correct
24 Correct 13 ms 1612 KB Output is correct
25 Correct 12 ms 1720 KB Output is correct
26 Correct 13 ms 1612 KB Output is correct
27 Correct 306 ms 43684 KB Output is correct
28 Correct 427 ms 43244 KB Output is correct
29 Correct 309 ms 44308 KB Output is correct
30 Correct 303 ms 42832 KB Output is correct
31 Correct 489 ms 44412 KB Output is correct
32 Correct 926 ms 63052 KB Output is correct
33 Correct 481 ms 45484 KB Output is correct
34 Correct 814 ms 47704 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 435 ms 28880 KB Output is correct
37 Correct 1805 ms 85892 KB Output is correct
38 Correct 2029 ms 86676 KB Output is correct
39 Correct 1740 ms 77852 KB Output is correct
40 Correct 678 ms 40396 KB Output is correct
41 Correct 285 ms 21660 KB Output is correct
42 Correct 28 ms 5064 KB Output is correct
43 Correct 2250 ms 85588 KB Output is correct
44 Correct 1261 ms 76432 KB Output is correct
45 Correct 1509 ms 85904 KB Output is correct
46 Correct 1311 ms 85916 KB Output is correct
47 Correct 700 ms 52952 KB Output is correct
48 Correct 1683 ms 88152 KB Output is correct
49 Correct 1381 ms 88204 KB Output is correct
50 Correct 536 ms 46860 KB Output is correct
51 Correct 11 ms 1612 KB Output is correct
52 Correct 9 ms 1760 KB Output is correct
53 Correct 9 ms 1744 KB Output is correct
54 Correct 26 ms 3072 KB Output is correct
55 Correct 24 ms 3072 KB Output is correct
56 Correct 25 ms 3020 KB Output is correct
57 Correct 85 ms 15912 KB Output is correct
58 Correct 102 ms 15444 KB Output is correct
59 Correct 112 ms 15680 KB Output is correct
60 Correct 425 ms 29932 KB Output is correct
61 Correct 433 ms 29980 KB Output is correct
62 Correct 404 ms 29876 KB Output is correct
63 Correct 574 ms 27824 KB Output is correct
64 Correct 620 ms 27864 KB Output is correct
65 Correct 619 ms 27868 KB Output is correct
66 Correct 320 ms 29792 KB Output is correct
67 Correct 329 ms 29596 KB Output is correct
68 Correct 288 ms 29588 KB Output is correct
69 Correct 409 ms 29600 KB Output is correct
70 Correct 315 ms 29572 KB Output is correct
71 Correct 386 ms 29636 KB Output is correct
72 Correct 333 ms 29572 KB Output is correct
73 Correct 323 ms 29568 KB Output is correct
74 Correct 294 ms 29604 KB Output is correct
75 Correct 441 ms 45584 KB Output is correct
76 Correct 421 ms 46032 KB Output is correct
77 Correct 254 ms 46048 KB Output is correct
78 Correct 366 ms 45576 KB Output is correct
79 Correct 609 ms 45808 KB Output is correct
80 Correct 354 ms 47076 KB Output is correct
81 Correct 1609 ms 88068 KB Output is correct
82 Correct 1692 ms 87836 KB Output is correct
83 Correct 2039 ms 87860 KB Output is correct
84 Correct 1491 ms 87856 KB Output is correct
85 Correct 1641 ms 87872 KB Output is correct
86 Correct 1857 ms 87900 KB Output is correct
87 Correct 1795 ms 87544 KB Output is correct
88 Correct 2576 ms 81484 KB Output is correct
89 Correct 2377 ms 81432 KB Output is correct
90 Correct 2219 ms 81544 KB Output is correct
91 Correct 1982 ms 81508 KB Output is correct
92 Correct 2159 ms 81628 KB Output is correct
93 Correct 1388 ms 87628 KB Output is correct
94 Correct 1581 ms 87340 KB Output is correct
95 Correct 1608 ms 87644 KB Output is correct
96 Correct 1414 ms 87500 KB Output is correct
97 Correct 1774 ms 87508 KB Output is correct
98 Correct 1244 ms 71872 KB Output is correct
99 Correct 1495 ms 87540 KB Output is correct
100 Correct 1748 ms 87476 KB Output is correct
101 Correct 1236 ms 78584 KB Output is correct
102 Correct 1897 ms 86708 KB Output is correct
103 Correct 1927 ms 86744 KB Output is correct
104 Correct 1657 ms 87156 KB Output is correct
105 Correct 821 ms 86740 KB Output is correct
106 Correct 1344 ms 84396 KB Output is correct
107 Correct 1358 ms 84540 KB Output is correct
108 Correct 1384 ms 84208 KB Output is correct
109 Correct 1387 ms 84176 KB Output is correct
110 Correct 1166 ms 84184 KB Output is correct
111 Correct 1102 ms 84116 KB Output is correct
112 Correct 1160 ms 84032 KB Output is correct
113 Correct 1374 ms 83976 KB Output is correct
114 Correct 1258 ms 83792 KB Output is correct
115 Correct 1112 ms 83916 KB Output is correct
116 Correct 1498 ms 83768 KB Output is correct