답안 #104327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104327 2019-04-05T06:21:29 Z dimash241 원 고르기 (APIO18_circle_selection) C++17
19 / 100
3000 ms 42824 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 * inf + 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;
    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 2 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 3 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 6 ms 640 KB Output is correct
22 Correct 22 ms 1152 KB Output is correct
23 Correct 17 ms 1152 KB Output is correct
24 Correct 18 ms 1152 KB Output is correct
25 Correct 17 ms 1152 KB Output is correct
26 Correct 21 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 13268 KB Output is correct
2 Correct 221 ms 12816 KB Output is correct
3 Correct 209 ms 13280 KB Output is correct
4 Correct 178 ms 12004 KB Output is correct
5 Correct 337 ms 12536 KB Output is correct
6 Correct 1506 ms 28232 KB Output is correct
7 Correct 432 ms 14580 KB Output is correct
8 Correct 598 ms 18364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 936 ms 15136 KB Output is correct
3 Execution timed out 3034 ms 42816 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3019 ms 42824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 3 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 6 ms 640 KB Output is correct
22 Correct 22 ms 1152 KB Output is correct
23 Correct 17 ms 1152 KB Output is correct
24 Correct 18 ms 1152 KB Output is correct
25 Correct 17 ms 1152 KB Output is correct
26 Correct 21 ms 1152 KB Output is correct
27 Correct 10 ms 1024 KB Output is correct
28 Correct 10 ms 896 KB Output is correct
29 Correct 11 ms 896 KB Output is correct
30 Correct 39 ms 1920 KB Output is correct
31 Correct 41 ms 1920 KB Output is correct
32 Correct 36 ms 1920 KB Output is correct
33 Correct 103 ms 4852 KB Output is correct
34 Correct 81 ms 4812 KB Output is correct
35 Correct 71 ms 4640 KB Output is correct
36 Correct 762 ms 15304 KB Output is correct
37 Correct 816 ms 15096 KB Output is correct
38 Correct 977 ms 15140 KB Output is correct
39 Correct 560 ms 14092 KB Output is correct
40 Correct 566 ms 14112 KB Output is correct
41 Correct 601 ms 14088 KB Output is correct
42 Correct 500 ms 15096 KB Output is correct
43 Correct 736 ms 15076 KB Output is correct
44 Incorrect 738 ms 15100 KB Output isn't correct
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 3 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 6 ms 640 KB Output is correct
22 Correct 22 ms 1152 KB Output is correct
23 Correct 17 ms 1152 KB Output is correct
24 Correct 18 ms 1152 KB Output is correct
25 Correct 17 ms 1152 KB Output is correct
26 Correct 21 ms 1152 KB Output is correct
27 Correct 229 ms 13268 KB Output is correct
28 Correct 221 ms 12816 KB Output is correct
29 Correct 209 ms 13280 KB Output is correct
30 Correct 178 ms 12004 KB Output is correct
31 Correct 337 ms 12536 KB Output is correct
32 Correct 1506 ms 28232 KB Output is correct
33 Correct 432 ms 14580 KB Output is correct
34 Correct 598 ms 18364 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 936 ms 15136 KB Output is correct
37 Execution timed out 3034 ms 42816 KB Time limit exceeded
38 Halted 0 ms 0 KB -