답안 #104328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104328 2019-04-05T06:23:23 Z dimash241 원 고르기 (APIO18_circle_selection) C++17
72 / 100
3000 ms 45152 KB
# include <stdio.h>
# include <bits/stdc++.h>
 
 
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
 
using namespace std;
inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; } 
inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}
 
const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;
 
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int id[N];
ll r[N];
ll x[N];
ll y[N];
int ans[N];
int lim;

bool cmp (int x, int y) { return r[x] > r[y] || (r[x] == r[y] && x < y); }
map < ll , vector < int > > q;
ll get (int x, int y) {
	return x * 5e9l + y;
}
void upd () {
	q.clear();
	for (int i = 1; i <= n; i ++) {
		if (!ans[i]) 
			q[get(x[i] / lim, y[i] / lim)].pb(i);
	}
}
ll sq (ll x) { return x * x; }

bool in (int i, int j) {
	return sq(x[i] - x[j]) + sq(y[i] - y[j]) <= sq(r[i] + r[j]);
}


int main () {
	SpeedForce;               

    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> x[i] >> y[i] >> r[i];
    	id[i] = i;
    }

    sort(id + 1, id + n + 1, &cmp);
    lim = inf - 1;
    vector < int > nq;
          	          
    for (int pos = 1, j, xx, yy; pos <= n; pos ++) {
    	j = id[pos];
    	
    	if (ans[j]) continue;

    	if (r[j] * 2 <= lim) {
    		lim = r[j];
    		upd ();
    	}
    	
    	ans[j] = j;
        xx = x[j] / lim, yy = y[j] / lim;
        for(int x = xx - 2; x <= xx + 2; x ++) {
            for(int y = yy - 2; y <= yy + 2; y ++) {
                if (q.find(get(x, y)) != q.end()) {
                	nq.clear();
                    for (auto i : q[get(x, y)]) {
                    	if (ans[i]) continue;
                        if(in(i, j)) {
                            ans[i] = j;
                        } else {
                            nq.push_back(i);
                        }
                    }
                    q[get(x, y)].swap(nq);
                }
            }
        }
    }
    for (int i = 1; i <= n; i ++)
    	cout << ans[i] << ' ';
    return Accepted;
}
 
// B...a D....
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 6 ms 640 KB Output is correct
22 Correct 17 ms 1128 KB Output is correct
23 Correct 19 ms 1152 KB Output is correct
24 Correct 21 ms 1152 KB Output is correct
25 Correct 18 ms 1152 KB Output is correct
26 Correct 16 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 13160 KB Output is correct
2 Correct 201 ms 12660 KB Output is correct
3 Correct 186 ms 13300 KB Output is correct
4 Correct 266 ms 11956 KB Output is correct
5 Correct 262 ms 12408 KB Output is correct
6 Correct 1086 ms 27968 KB Output is correct
7 Correct 442 ms 14344 KB Output is correct
8 Correct 612 ms 18312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 770 ms 15092 KB Output is correct
3 Correct 2910 ms 44548 KB Output is correct
4 Correct 2807 ms 44800 KB Output is correct
5 Correct 2831 ms 38340 KB Output is correct
6 Correct 1020 ms 19036 KB Output is correct
7 Correct 409 ms 10488 KB Output is correct
8 Correct 44 ms 2680 KB Output is correct
9 Execution timed out 3008 ms 41976 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2216 ms 44624 KB Output is correct
2 Correct 1681 ms 44888 KB Output is correct
3 Correct 785 ms 21880 KB Output is correct
4 Correct 1771 ms 44724 KB Output is correct
5 Correct 1736 ms 45152 KB Output is correct
6 Correct 411 ms 15584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 6 ms 640 KB Output is correct
22 Correct 17 ms 1128 KB Output is correct
23 Correct 19 ms 1152 KB Output is correct
24 Correct 21 ms 1152 KB Output is correct
25 Correct 18 ms 1152 KB Output is correct
26 Correct 16 ms 1152 KB Output is correct
27 Correct 8 ms 896 KB Output is correct
28 Correct 13 ms 868 KB Output is correct
29 Correct 9 ms 896 KB Output is correct
30 Correct 50 ms 1920 KB Output is correct
31 Correct 41 ms 1948 KB Output is correct
32 Correct 49 ms 1912 KB Output is correct
33 Correct 75 ms 5064 KB Output is correct
34 Correct 72 ms 5080 KB Output is correct
35 Correct 106 ms 4712 KB Output is correct
36 Correct 701 ms 15396 KB Output is correct
37 Correct 731 ms 15388 KB Output is correct
38 Correct 807 ms 15520 KB Output is correct
39 Correct 606 ms 14364 KB Output is correct
40 Correct 617 ms 14248 KB Output is correct
41 Correct 598 ms 14240 KB Output is correct
42 Correct 515 ms 15384 KB Output is correct
43 Correct 477 ms 15168 KB Output is correct
44 Correct 508 ms 15280 KB Output is correct
45 Correct 474 ms 15340 KB Output is correct
46 Correct 500 ms 15292 KB Output is correct
47 Correct 531 ms 15428 KB Output is correct
48 Correct 465 ms 15356 KB Output is correct
49 Correct 453 ms 15300 KB Output is correct
50 Correct 417 ms 15352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 6 ms 640 KB Output is correct
22 Correct 17 ms 1128 KB Output is correct
23 Correct 19 ms 1152 KB Output is correct
24 Correct 21 ms 1152 KB Output is correct
25 Correct 18 ms 1152 KB Output is correct
26 Correct 16 ms 1152 KB Output is correct
27 Correct 192 ms 13160 KB Output is correct
28 Correct 201 ms 12660 KB Output is correct
29 Correct 186 ms 13300 KB Output is correct
30 Correct 266 ms 11956 KB Output is correct
31 Correct 262 ms 12408 KB Output is correct
32 Correct 1086 ms 27968 KB Output is correct
33 Correct 442 ms 14344 KB Output is correct
34 Correct 612 ms 18312 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 770 ms 15092 KB Output is correct
37 Correct 2910 ms 44548 KB Output is correct
38 Correct 2807 ms 44800 KB Output is correct
39 Correct 2831 ms 38340 KB Output is correct
40 Correct 1020 ms 19036 KB Output is correct
41 Correct 409 ms 10488 KB Output is correct
42 Correct 44 ms 2680 KB Output is correct
43 Execution timed out 3008 ms 41976 KB Time limit exceeded
44 Halted 0 ms 0 KB -