Submission #361317

# Submission time Handle Problem Language Result Execution time Memory
361317 2021-01-29T09:19:34 Z AmShZ Circle selection (APIO18_circle_selection) C++11
19 / 100
1086 ms 126316 KB
//khodaya khodet komak kon
# include <bits/stdc++.h>
 
/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <ll, ll>                                    pll;
typedef pair <pll, pll>                                  ppp;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define lc                                              id << 1
# define rc                                              id << 1 | 1
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
 
const int xn = 3e5 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 998244353;
const int base = 257;

int n, ans[xn];
ppp a[xn], b[xn];
vector <int> adj[xn];
set <pii> st[2];
bool mark[xn];

void solve(){
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++ i){
		int id = a[i].A.B;
		int x = a[i].B.A, y = a[i].B.B;
		int l = x + a[i].A.A, r = x - a[i].A.A;
		if (st[0].find({l, id}) == st[0].end())
			continue;
		ans[id] = id;
		st[0].erase({l, id}), st[1].erase({- r, id});
		while (st[0].lower_bound({l, id}) != st[0].end()){
			pii x = *st[0].lower_bound({l, id});
			if (x.A > r)
				break;
			ans[x.B] = id;
			st[0].erase(x);
			st[1].erase({b[x.B].A.A - b[x.B].B.A, x.B});
		}
		while (st[1].lower_bound({- r, id}) != st[1].end()){
			pii x = *st[1].lower_bound({- r, id});
			if (- x.A < l)
				break;
			ans[x.B] = id;
			st[1].erase(x);
			st[0].erase({b[x.B].B.A + b[x.B].A.A, x.B});
		}
	}
	for (int i = 1; i <= n; ++ i)
		cout << ans[i] << sep;
	cout << endl;
}

int main(){
	InTheNameOfGod;
	
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		cin >> a[i].B.A >> a[i].B.B >> a[i].A.A;
		a[i].A.B = i;
		st[0].insert({a[i].B.A - a[i].A.A, i});
		st[1].insert({- a[i].A.A - a[i].B.A, i});
		a[i].A.A *= - 1;
		b[i] = a[i];
	}
	if (n > 5e3){
		solve();
		return 0;
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= n; ++ j){
			ll x = abs(a[i].B.A - a[j].B.A);
			ll y = abs(a[i].B.B - a[j].B.B);
			ll z = - a[i].A.A - a[j].A.A;
			if (x * x + y * y <= z * z)
				adj[i].push_back(j);
		}
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++ i){
		if (mark[a[i].A.B])
			continue;
		for (int u : adj[a[i].A.B])
			if (!mark[u])
				mark[u] = true, ans[u] = a[i].A.B;
	}
	for (int i = 1; i <= n; ++ i)
		cout << ans[i] << sep;
	cout << endl;
			
	return 0;
}

Compilation message

circle_selection.cpp: In function 'void solve()':
circle_selection.cpp:53:21: warning: unused variable 'y' [-Wunused-variable]
   53 |   int x = a[i].B.A, y = a[i].B.B;
      |                     ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7552 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 5 ms 7424 KB Output is correct
5 Correct 5 ms 7404 KB Output is correct
6 Correct 6 ms 7532 KB Output is correct
7 Correct 6 ms 7532 KB Output is correct
8 Correct 6 ms 7404 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 5 ms 7404 KB Output is correct
11 Correct 5 ms 7404 KB Output is correct
12 Correct 5 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 6 ms 7424 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 16 ms 11372 KB Output is correct
17 Correct 17 ms 11116 KB Output is correct
18 Correct 16 ms 11628 KB Output is correct
19 Correct 202 ms 123116 KB Output is correct
20 Correct 198 ms 126316 KB Output is correct
21 Correct 265 ms 82432 KB Output is correct
22 Correct 93 ms 8428 KB Output is correct
23 Correct 92 ms 8556 KB Output is correct
24 Correct 97 ms 8428 KB Output is correct
25 Correct 93 ms 8428 KB Output is correct
26 Correct 100 ms 8476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1081 ms 57744 KB Output is correct
2 Correct 1044 ms 64364 KB Output is correct
3 Correct 1086 ms 64140 KB Output is correct
4 Correct 1077 ms 64636 KB Output is correct
5 Correct 949 ms 62080 KB Output is correct
6 Correct 1066 ms 62268 KB Output is correct
7 Correct 963 ms 62444 KB Output is correct
8 Correct 985 ms 62208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Incorrect 247 ms 24140 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 838 ms 57380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7552 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 5 ms 7424 KB Output is correct
5 Correct 5 ms 7404 KB Output is correct
6 Correct 6 ms 7532 KB Output is correct
7 Correct 6 ms 7532 KB Output is correct
8 Correct 6 ms 7404 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 5 ms 7404 KB Output is correct
11 Correct 5 ms 7404 KB Output is correct
12 Correct 5 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 6 ms 7424 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 16 ms 11372 KB Output is correct
17 Correct 17 ms 11116 KB Output is correct
18 Correct 16 ms 11628 KB Output is correct
19 Correct 202 ms 123116 KB Output is correct
20 Correct 198 ms 126316 KB Output is correct
21 Correct 265 ms 82432 KB Output is correct
22 Correct 93 ms 8428 KB Output is correct
23 Correct 92 ms 8556 KB Output is correct
24 Correct 97 ms 8428 KB Output is correct
25 Correct 93 ms 8428 KB Output is correct
26 Correct 100 ms 8476 KB Output is correct
27 Incorrect 22 ms 9068 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7552 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 5 ms 7424 KB Output is correct
5 Correct 5 ms 7404 KB Output is correct
6 Correct 6 ms 7532 KB Output is correct
7 Correct 6 ms 7532 KB Output is correct
8 Correct 6 ms 7404 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 5 ms 7404 KB Output is correct
11 Correct 5 ms 7404 KB Output is correct
12 Correct 5 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 6 ms 7424 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 16 ms 11372 KB Output is correct
17 Correct 17 ms 11116 KB Output is correct
18 Correct 16 ms 11628 KB Output is correct
19 Correct 202 ms 123116 KB Output is correct
20 Correct 198 ms 126316 KB Output is correct
21 Correct 265 ms 82432 KB Output is correct
22 Correct 93 ms 8428 KB Output is correct
23 Correct 92 ms 8556 KB Output is correct
24 Correct 97 ms 8428 KB Output is correct
25 Correct 93 ms 8428 KB Output is correct
26 Correct 100 ms 8476 KB Output is correct
27 Correct 1081 ms 57744 KB Output is correct
28 Correct 1044 ms 64364 KB Output is correct
29 Correct 1086 ms 64140 KB Output is correct
30 Correct 1077 ms 64636 KB Output is correct
31 Correct 949 ms 62080 KB Output is correct
32 Correct 1066 ms 62268 KB Output is correct
33 Correct 963 ms 62444 KB Output is correct
34 Correct 985 ms 62208 KB Output is correct
35 Correct 5 ms 7404 KB Output is correct
36 Incorrect 247 ms 24140 KB Output isn't correct
37 Halted 0 ms 0 KB -