Logo
(追記) (追記ここまで)

7149번 - Can of Worms 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 128 MB141523435.417%

문제

There is an old adage about opening a can of worms. A lesser known adage is one about shooting a can of exploding worms with a BB gun.

Imagine we place some cans of exploding worms on a long, straight fence. When a can is shot, all of the worms inside will explode. Different types of worms have different blast radii. Each can contains only one kind of worm.

When a can explodes, if another can is in the blast radius, then that can will also explode, possibly creating a chain reaction. Each can explodes only once. This process continues until all explosions stop.

For each can, suppose that it is the only can shot. How many cans in total will explode?

입력

There will be several test cases in the input. Each test case will begin with a line with a single integer n (1≤n≤100,000) representing the number of cans on that fence. Each of the next n lines will have two integers x (-109≤x≤109) and r(1≤r≤109), where x is the location of the can on the fence and r is the blast radius. No two cans will occupy the same location. The input will end with a line with a single 0.

출력

For each fence, print n integers on a single line separated by single spaces. The ith integer represents the number of cans that will explode if the ith can is the one that is shot. Output no extra spaces, and do not print any blank lines between outputs.

제한

예제 입력 1

3
4 3
-10 9
-2 3
12
2 2
7 7
10 1
19 3
23 12
29 8
33 1
35 17
39 2
40 1
46 11
52 3
0

예제 출력 1

1 2 1
1 3 1 1 9 9 1 9 2 2 9 1

힌트

출처

University > North American Invitational Programming Contest > UCIPC 2013 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /