답안 #111182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111182 2019-05-14T03:07:32 Z oToToT 원 고르기 (APIO18_circle_selection) C++14
72 / 100
3000 ms 293052 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;

static inline int gc() {
  static char buf[1 << 20], *p = buf, *end = buf;
  if (p == end) {
    if ((end = buf + fread(buf, 1, 1 << 20, stdin)) == buf) return EOF;
    p = buf;
  }
  return *p++;
}
template<typename T>
static inline bool gn(T &_){
  register int c = gc(); register T __ = 1; _ = 0;
  while(!isdigit(c) and c!=EOF and c!='-') c = gc();
  if(c == '-') { __ = -1; c = gc(); }
  if(c == EOF) return false;
  while(isdigit(c)) _ = _ * 10 + c - '0', c = gc();
  _ *= __;
  return true;
}
template <typename T, typename ...Args>
static inline bool gn(T &x, Args& ...args){return gn(x) and gn(args...);}

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() {
	gn( n );
	for ( int i = 0 ; i < n ; ++ i )
		gn( 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 )
		printf( "%d%c", ans[ i ], " \n"[ i == n - 1 ] );
}

int main() {
	init(); solve();
	return 0;
}
# 결과 실행 시간 메모리 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 3 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 3 ms 384 KB Output is correct
12 Correct 3 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 3 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 4 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 22 ms 2304 KB Output is correct
23 Correct 18 ms 2176 KB Output is correct
24 Correct 19 ms 2176 KB Output is correct
25 Correct 22 ms 3072 KB Output is correct
26 Correct 18 ms 2560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 17328 KB Output is correct
2 Correct 144 ms 17868 KB Output is correct
3 Correct 158 ms 18268 KB Output is correct
4 Correct 148 ms 16460 KB Output is correct
5 Correct 159 ms 17484 KB Output is correct
6 Correct 1032 ms 37068 KB Output is correct
7 Correct 245 ms 18636 KB Output is correct
8 Correct 375 ms 20300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 795 ms 32372 KB Output is correct
3 Execution timed out 3033 ms 88268 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2718 ms 186596 KB Output is correct
2 Correct 1777 ms 293052 KB Output is correct
3 Correct 247 ms 18512 KB Output is correct
4 Correct 1601 ms 239776 KB Output is correct
5 Correct 1833 ms 272788 KB Output is correct
6 Correct 168 ms 16972 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 384 KB Output is correct
12 Correct 3 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 3 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 4 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 22 ms 2304 KB Output is correct
23 Correct 18 ms 2176 KB Output is correct
24 Correct 19 ms 2176 KB Output is correct
25 Correct 22 ms 3072 KB Output is correct
26 Correct 18 ms 2560 KB Output is correct
27 Correct 9 ms 1276 KB Output is correct
28 Correct 7 ms 1308 KB Output is correct
29 Correct 6 ms 1280 KB Output is correct
30 Correct 49 ms 4280 KB Output is correct
31 Correct 55 ms 4608 KB Output is correct
32 Correct 45 ms 3960 KB Output is correct
33 Correct 42 ms 6888 KB Output is correct
34 Correct 45 ms 6888 KB Output is correct
35 Correct 47 ms 6220 KB Output is correct
36 Correct 1093 ms 37288 KB Output is correct
37 Correct 977 ms 33380 KB Output is correct
38 Correct 1065 ms 36712 KB Output is correct
39 Correct 170 ms 8228 KB Output is correct
40 Correct 190 ms 8268 KB Output is correct
41 Correct 171 ms 8236 KB Output is correct
42 Correct 74 ms 8044 KB Output is correct
43 Correct 470 ms 84716 KB Output is correct
44 Correct 479 ms 84824 KB Output is correct
45 Correct 492 ms 84988 KB Output is correct
46 Correct 495 ms 84908 KB Output is correct
47 Correct 520 ms 85008 KB Output is correct
48 Correct 520 ms 84972 KB Output is correct
49 Correct 521 ms 84840 KB Output is correct
50 Correct 603 ms 84876 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 3 ms 384 KB Output is correct
12 Correct 3 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 3 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 4 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 22 ms 2304 KB Output is correct
23 Correct 18 ms 2176 KB Output is correct
24 Correct 19 ms 2176 KB Output is correct
25 Correct 22 ms 3072 KB Output is correct
26 Correct 18 ms 2560 KB Output is correct
27 Correct 184 ms 17328 KB Output is correct
28 Correct 144 ms 17868 KB Output is correct
29 Correct 158 ms 18268 KB Output is correct
30 Correct 148 ms 16460 KB Output is correct
31 Correct 159 ms 17484 KB Output is correct
32 Correct 1032 ms 37068 KB Output is correct
33 Correct 245 ms 18636 KB Output is correct
34 Correct 375 ms 20300 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 795 ms 32372 KB Output is correct
37 Execution timed out 3033 ms 88268 KB Time limit exceeded
38 Halted 0 ms 0 KB -