포럼
문제 ICPC00245

C. Compass Card Sales

설명

Katla has recently stopped playing the collectible card game Compass. As you might remember, Compass is a game where each card has a red, a green and a blue angle, each one between \(0\) and \(359\), as well as an ID. Since she has stopped playing, Katla has decided to sell all her cards. However, she wants to keep her deck as unique as possible while selling off the cards. Can you help her figure out the order in which she should sell the cards?

To decide how unique a card is in the deck, she proceeds as follows. For each of the three colors she finds the closest other card in both directions, and then computes the angle between these two other cards. For instance if she has three cards with red angles \(42\), \(90\) and \(110\), then the uniqueness values of their red angles are \(340\), \(68\), and \(312\), respectively. If two cards \(A\) and \(B\) have the same angle, \(B\) is considered the closest to \(A\) in both directions so that the uniqueness value of \(A\) (and \(B\)) for that color is \(0\).

By summing the uniqueness values over the three colours, Katla finds how unique each card is. When selling a card, Katla sells the currently least unique card (smallest uniqueness value). If two cards have the same uniqueness value, she will sell the one with the higher ID first. After each card is sold, the uniqueness values of the remaining cards are updated before selling the next card.

제약
입력 형식

The first line of input contains an integer \(n\), the number of cards (\(1 \le n \le 10^5\)). Then follows \(n\) lines. Each of these \(n\) lines contains \(4\) integers $r,
g, b, \text{id}\( (\)0 \le r, g, b < 360\(, \)0 \le \text{id} <
2^{31}$), giving the red, green and blue angles as well as the ID of a card. No two cards have the same ID.

출력 형식

Output \(n\) lines, containing the IDs of the cards in the order they are to be sold, from first (least unique) to last (most unique).

예제 1
입력
3
42 1 1 1
90 1 1 2
110 1 1 3
출력
2
3
1
예제 2
입력
4
0 0 0 0
120 120 120 120
240 240 240 240
0 120 240 2017
출력
2017
240
120
0
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2017

평가 및 의견

C. Compass Card Sales

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

C. Compass Card Sales

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8