답안 #59916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59916 2018-07-23T10:08:34 Z Eae02 원 고르기 (APIO18_circle_selection) C++14
0 / 100
963 ms 21488 KB
#include <bits/stdc++.h>
#define ALL(x) x.begin(),x.end()

struct Circle
{
	int64_t x;
	int64_t y;
	int64_t r;
	int64_t i;
	int64_t elimBy;
	
	int64_t minX() const
	{
		return x - r;
	}
	int64_t maxX() const
	{
		return x + r;
	}
};

int main()
{
	int num;
	std::cin >> num;
	std::vector<Circle> circles(num);
	std::vector<Circle*> cByMin(num);
	std::vector<Circle*> cByMax(num);
	
	for (int i = 0; i < num; i++)
	{
		std::cin >> circles[i].x;
		std::cin >> circles[i].y;
		std::cin >> circles[i].r;
		circles[i].i = i;
		circles[i].elimBy = -1;
		cByMin[i] = &circles[i];
		cByMax[i] = &circles[i];
	}
	
	std::sort(ALL(circles), [&] (const Circle& a, const Circle& b)
	{
		if (a.r == b.r)
			return a.i < b.i;
		return a.r > b.r;
	});
	
	std::sort(ALL(cByMin), [&] (const Circle* a, const Circle* b)
	{
		return a->minX() < b->minX();
	});
	
	std::sort(ALL(cByMax), [&] (const Circle* a, const Circle* b)
	{
		return a->maxX() < b->maxX();
	});
	
	for (int i = 0; i < num; i++)
	{
		if (circles[i].elimBy != -1)
			continue;
		circles[i].elimBy = circles[i].i;
		
		auto minB = std::lower_bound(ALL(cByMin), circles[i].minX(), [&] (Circle* c, int64_t pos) { return c->minX() < pos; });
		auto minE = std::upper_bound(ALL(cByMin), circles[i].maxX(), [&] (int64_t pos, Circle* c) { return pos < c->minX(); });
		
		auto maxB = std::lower_bound(ALL(cByMax), circles[i].minX(), [&] (Circle* c, int64_t pos) { return c->maxX() <= pos; });
		auto maxE = std::upper_bound(ALL(cByMax), circles[i].maxX(), [&] (int64_t pos, Circle* c) { return pos <= c->maxX(); });
		
		std::for_each(minB, minE, [&] (Circle* c)
		{
			if (c->elimBy == -1)
				c->elimBy = circles[i].i;
		});
		std::for_each(maxB, maxE, [&] (Circle* c)
		{
			if (c->elimBy == -1)
				c->elimBy = circles[i].i;
		});
	}
	
	std::vector<int64_t> result(num);
	for (int i = 0; i < num; i++)
		result[circles[i].i] = circles[i].elimBy + 1;
	for (int i = 0; i < num; i++)
		std::cout << result[i] << " ";
	std::cout << std::endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Incorrect 2 ms 544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 643 ms 21328 KB Output is correct
2 Correct 963 ms 21400 KB Output is correct
3 Correct 773 ms 21400 KB Output is correct
4 Correct 777 ms 21488 KB Output is correct
5 Incorrect 668 ms 21488 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 21488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 775 ms 21488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Incorrect 2 ms 544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Incorrect 2 ms 544 KB Output isn't correct
4 Halted 0 ms 0 KB -