Submission #111181

# Submission time Handle Problem Language Result Execution time Memory
111181 2019-05-14T03:03:47 Z oToToT Circle selection (APIO18_circle_selection) C++17
72 / 100
3000 ms 298940 KB
#pragma GCC optimize( "O3" )
#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 5;
const int C = 1000000000;
template < typename A, typename B >
using UMP = unordered_map< A, B >;
using lld = int64_t;

int n;
vector< int > ord;
lld x[ N ], y[ N ], r[ N ];

inline bool inter( int i, int j ) {
	const lld ox = x[ i ] - x[ j ];
	const lld oy = y[ i ] - y[ j ];
	const lld R = r[ i ] + r[ j ];
	return ox * ox + oy * oy <= R * R;
}

void init() {
	cin >> n;
	for ( int i = 0 ; i < n ; ++ i )
		cin >> x[ i ] >> y[ i ] >> r[ i ];
	for ( int i = 0 ; i < n ; ++ i )
		x[ i ] += C, y[ i ] += C;

	ord.resize( n );
	iota( ord.begin(), ord.end(), 0 );
	sort( ord.begin(), ord.end(), []( int a, int b ) {
		return tie( r[ a ], b ) > tie( r[ b ], a );
	} );
}

UMP< lld, UMP< lld, vector< int > > > plane;
int ans[ N ];
int LogL = 32;
lld unit = 1;
inline void build() {
	plane.clear(); plane.rehash( n );
	for ( int i = 0 ; i < n ; ++ i ) {
		if ( ans[ i ] ) continue;
		plane[ x[ i ] >> LogL ][ y[ i ] >> LogL ].push_back( i );
	}
}

const int dx[] = { -1, 0, 1 }, dy[] = { -1, 0, 1 };

void solve() {
	build();
	for ( int i : ord ) {
		if ( ans[ i ] ) continue;
		ans[ i ] = i + 1;
		int pLogL = LogL;
		while( ( unit << ( -- LogL ) ) > r[ i ] + r[ i ] );
		if ( pLogL != ++ LogL ) build();
		lld X = x[ i ] >> LogL, Y = y[ i ] >> LogL;
		for ( int i_ = 0 ; i_ < 3 ; ++ i_ ) {
			for ( int j_ = 0 ; j_ < 3 ; ++ j_ ) {
				for ( int j : plane[ X + dx[ i_ ] ][ Y + dy[ j_ ] ] ) {
					if ( ans[ j ] ) continue;
					if ( inter( i, j ) ) ans[ j ] = i + 1;
				}
			}
		}
	}
	for ( int i = 0 ; i < n ; ++ i )
		cout << ans[ i ] << " \n"[ i == n - 1 ];
}

int main() {
	ios_base::sync_with_stdio( false );
	cin.tie( nullptr );
	init(); solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 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 2 ms 512 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 3 ms 384 KB Output is correct
13 Correct 2 ms 484 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 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 7 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 16 ms 2296 KB Output is correct
23 Correct 18 ms 2176 KB Output is correct
24 Correct 17 ms 2176 KB Output is correct
25 Correct 28 ms 2944 KB Output is correct
26 Correct 29 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 23016 KB Output is correct
2 Correct 226 ms 23572 KB Output is correct
3 Correct 207 ms 23848 KB Output is correct
4 Correct 180 ms 22132 KB Output is correct
5 Correct 195 ms 21072 KB Output is correct
6 Correct 975 ms 40564 KB Output is correct
7 Correct 303 ms 22288 KB Output is correct
8 Correct 352 ms 24016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1006 ms 33888 KB Output is correct
3 Execution timed out 3021 ms 95300 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2846 ms 193272 KB Output is correct
2 Correct 1826 ms 298940 KB Output is correct
3 Correct 261 ms 26064 KB Output is correct
4 Correct 1718 ms 246160 KB Output is correct
5 Correct 2029 ms 279252 KB Output is correct
6 Correct 204 ms 24532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 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 2 ms 512 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 3 ms 384 KB Output is correct
13 Correct 2 ms 484 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 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 7 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 16 ms 2296 KB Output is correct
23 Correct 18 ms 2176 KB Output is correct
24 Correct 17 ms 2176 KB Output is correct
25 Correct 28 ms 2944 KB Output is correct
26 Correct 29 ms 2688 KB Output is correct
27 Correct 10 ms 1152 KB Output is correct
28 Correct 10 ms 1152 KB Output is correct
29 Correct 9 ms 1152 KB Output is correct
30 Correct 37 ms 4224 KB Output is correct
31 Correct 41 ms 4728 KB Output is correct
32 Correct 37 ms 3864 KB Output is correct
33 Correct 66 ms 8944 KB Output is correct
34 Correct 68 ms 8940 KB Output is correct
35 Correct 75 ms 8044 KB Output is correct
36 Correct 858 ms 38888 KB Output is correct
37 Correct 793 ms 34792 KB Output is correct
38 Correct 852 ms 38252 KB Output is correct
39 Correct 186 ms 8188 KB Output is correct
40 Correct 207 ms 8184 KB Output is correct
41 Correct 218 ms 8248 KB Output is correct
42 Correct 125 ms 8556 KB Output is correct
43 Correct 586 ms 86364 KB Output is correct
44 Correct 572 ms 86508 KB Output is correct
45 Correct 568 ms 86332 KB Output is correct
46 Correct 565 ms 86360 KB Output is correct
47 Correct 627 ms 86508 KB Output is correct
48 Correct 602 ms 86552 KB Output is correct
49 Correct 499 ms 86484 KB Output is correct
50 Correct 532 ms 86276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 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 2 ms 512 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 3 ms 384 KB Output is correct
13 Correct 2 ms 484 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 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 7 ms 768 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 16 ms 2296 KB Output is correct
23 Correct 18 ms 2176 KB Output is correct
24 Correct 17 ms 2176 KB Output is correct
25 Correct 28 ms 2944 KB Output is correct
26 Correct 29 ms 2688 KB Output is correct
27 Correct 188 ms 23016 KB Output is correct
28 Correct 226 ms 23572 KB Output is correct
29 Correct 207 ms 23848 KB Output is correct
30 Correct 180 ms 22132 KB Output is correct
31 Correct 195 ms 21072 KB Output is correct
32 Correct 975 ms 40564 KB Output is correct
33 Correct 303 ms 22288 KB Output is correct
34 Correct 352 ms 24016 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 1006 ms 33888 KB Output is correct
37 Execution timed out 3021 ms 95300 KB Time limit exceeded
38 Halted 0 ms 0 KB -