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

26327번 - Knightmare 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB62266.667%

문제

Probably the night before this contest you had a great sense of anticipation. While sleeping, you had a horrible nightmare about an impossibly difficult chess problem. Well, here it is!

Given a large number of knights on an infinite chessboard, determine the number of squares each of which is currently being threatened by k or more knights. Unfortunately for you, these are not normal knights! They can move in the following way. Each knight has two values, a and b. For any two integers, i (1 ≤ i ≤ a) and j (1 ≤ j ≤ b), the knight can move to any of the following squares relative to its current location: (i, j), (-i, j), (i, -j), (-i, -j), (-j, -i), (-j, i), (j, -i), (j, i). Any of these squares are considered threatened.

입력

The first line of the input contains a single positive integer, n, representing the number of boards to analyze. Each board starts with a new line containing two integers, p (1 ≤ p ≤ 105) and k (1 ≤ k ≤ 10), representing the number of knights and the value k from above, respectively. This is followed by p lines representing each knight. Each of these p lines contains four integers, r, c, a and b (0 ≤ r ≤ 109; 0 ≤ c ≤ 109; 1 ≤ a ≤ 109; 1 ≤ b ≤ 109), representing the row and column the knight occupies as well as its a and b values (from above).

출력

For each board, output the number of squares each of which threatened by k or more knights.

제한

예제 입력 1

3
2 10
10 10 2 1
10 10 1 2
1 1
10 10 2 1
2 2
10 10 2 2
13 10 2 2

예제 출력 1

0
12
8

힌트

출처

University > University of Central Florida > 2013 Local Programming Contest 2번

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

출처

대학교 대회

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

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