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

5855번 - Square Overlap 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB91301937.255%

문제

Farmer John is planning to build N (2 <= N <= 50,000) square fenced-in pastures on his farm, each of size exactly K x K (1 <= K <= 1,000,000). Pasture i is centered at point (x_i, y_i) with integer coordinates in the range -1,000,000...1,000,000. However, in his haste to complete his plans, FJ realizes that he may have accidentally placed two pastures in locations that overlap (by overlap, this means the two pastures share a positive area in common). No two pastures share the exact same center point.

Given the locations of each of the planned square pastures, please help FJ compute the area shared by the two overlapping pastures. Output zero if no two squares overlap, and -1 if overlap occurs between more than a single pair of pastures.

입력

  • Line 1: Two space-separated integers, N and K. K is guaranteed to be even.
  • Lines 2..1+N: Line i+1 contains the integers x_i and y_i, describing the center of the ith pasture.

출력

  • Line 1: The area shared by the two overlapping squares. Output zero if no two squares overlap, and -1 if overlap occurs between more than a single pair of pastures.

제한

예제 입력 1

4 6
0 0
8 4
-2 1
0 7

예제 출력 1

20

힌트

Input Details

There are 4 squares, each of size 6 x 6. The first square is centered at (0,0), and so on.

Output Details

Pastures #1 and #3 overlap in 20 units of area.

출처

Olympiad > USA Computing Olympiad > 2012-2013 Season > USACO January 2013 Contest > Silver 2번

  • 데이터를 추가한 사람: devbelly
(追記) (追記ここまで)

출처

대학교 대회

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

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