Submission #415050

# Submission time Handle Problem Language Result Execution time Memory
415050 2021-05-31T13:24:34 Z hhhhaura Circle selection (APIO18_circle_selection) C++14
49 / 100
3000 ms 364104 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 rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

#define INF 100
#define MOD 1000000007
#define eps (1e-9)

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

using namespace std;

#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define x first
#define y second
namespace solver {
	int n, r, c, w, ii;
	vector<vector<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, vector<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]].push_back(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;
			for(auto j : v[mp[i]]) if(!vis[j]) {
				if(dis2(a[j], a[x]) <= 
					(rad[j] + rad[x]) * (rad[j] + rad[x])) {
					vis[j] = x;
				}
			}	
		}
		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)
      | 
circle_selection.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L; }
      |             ^~~~
circle_selection.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L; }
      |                     ^~~~
# Verdict Execution time Memory 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 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 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 2 ms 332 KB Output is correct
14 Correct 2 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 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 4 ms 856 KB Output is correct
20 Correct 5 ms 844 KB Output is correct
21 Correct 5 ms 844 KB Output is correct
22 Correct 12 ms 1620 KB Output is correct
23 Correct 13 ms 1996 KB Output is correct
24 Correct 12 ms 1612 KB Output is correct
25 Correct 12 ms 1996 KB Output is correct
26 Correct 13 ms 1988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 31900 KB Output is correct
2 Correct 224 ms 32180 KB Output is correct
3 Correct 209 ms 31800 KB Output is correct
4 Correct 211 ms 31892 KB Output is correct
5 Correct 246 ms 30388 KB Output is correct
6 Correct 963 ms 53604 KB Output is correct
7 Correct 286 ms 31384 KB Output is correct
8 Correct 420 ms 34360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 400 ms 13760 KB Output is correct
3 Correct 2507 ms 39276 KB Output is correct
4 Correct 2450 ms 39484 KB Output is correct
5 Correct 2333 ms 36612 KB Output is correct
6 Correct 841 ms 19292 KB Output is correct
7 Correct 254 ms 10904 KB Output is correct
8 Correct 33 ms 3496 KB Output is correct
9 Correct 2519 ms 40772 KB Output is correct
10 Execution timed out 3047 ms 33536 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 1793 ms 43948 KB Output is correct
2 Execution timed out 3038 ms 364104 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 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 2 ms 332 KB Output is correct
14 Correct 2 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 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 4 ms 856 KB Output is correct
20 Correct 5 ms 844 KB Output is correct
21 Correct 5 ms 844 KB Output is correct
22 Correct 12 ms 1620 KB Output is correct
23 Correct 13 ms 1996 KB Output is correct
24 Correct 12 ms 1612 KB Output is correct
25 Correct 12 ms 1996 KB Output is correct
26 Correct 13 ms 1988 KB Output is correct
27 Correct 9 ms 1484 KB Output is correct
28 Correct 9 ms 1400 KB Output is correct
29 Correct 9 ms 1356 KB Output is correct
30 Correct 27 ms 2992 KB Output is correct
31 Correct 23 ms 2056 KB Output is correct
32 Correct 22 ms 2884 KB Output is correct
33 Correct 76 ms 11596 KB Output is correct
34 Correct 81 ms 11900 KB Output is correct
35 Correct 85 ms 11376 KB Output is correct
36 Correct 344 ms 15924 KB Output is correct
37 Correct 515 ms 17388 KB Output is correct
38 Correct 382 ms 14608 KB Output is correct
39 Correct 369 ms 16372 KB Output is correct
40 Correct 510 ms 16500 KB Output is correct
41 Correct 501 ms 16548 KB Output is correct
42 Correct 516 ms 10364 KB Output is correct
43 Correct 416 ms 51360 KB Output is correct
44 Correct 531 ms 51484 KB Output is correct
45 Correct 464 ms 51544 KB Output is correct
46 Correct 498 ms 51488 KB Output is correct
47 Correct 515 ms 51508 KB Output is correct
48 Correct 494 ms 51464 KB Output is correct
49 Correct 381 ms 51436 KB Output is correct
50 Correct 425 ms 51484 KB Output is correct
# Verdict Execution time Memory 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 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 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 2 ms 332 KB Output is correct
14 Correct 2 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 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 4 ms 856 KB Output is correct
20 Correct 5 ms 844 KB Output is correct
21 Correct 5 ms 844 KB Output is correct
22 Correct 12 ms 1620 KB Output is correct
23 Correct 13 ms 1996 KB Output is correct
24 Correct 12 ms 1612 KB Output is correct
25 Correct 12 ms 1996 KB Output is correct
26 Correct 13 ms 1988 KB Output is correct
27 Correct 239 ms 31900 KB Output is correct
28 Correct 224 ms 32180 KB Output is correct
29 Correct 209 ms 31800 KB Output is correct
30 Correct 211 ms 31892 KB Output is correct
31 Correct 246 ms 30388 KB Output is correct
32 Correct 963 ms 53604 KB Output is correct
33 Correct 286 ms 31384 KB Output is correct
34 Correct 420 ms 34360 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 400 ms 13760 KB Output is correct
37 Correct 2507 ms 39276 KB Output is correct
38 Correct 2450 ms 39484 KB Output is correct
39 Correct 2333 ms 36612 KB Output is correct
40 Correct 841 ms 19292 KB Output is correct
41 Correct 254 ms 10904 KB Output is correct
42 Correct 33 ms 3496 KB Output is correct
43 Correct 2519 ms 40772 KB Output is correct
44 Execution timed out 3047 ms 33536 KB Time limit exceeded