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

13920번 - Orchard Division 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB528723.333%

문제

Uncle Oliver is going to sell a significant part of his famous dwarf plum tree orchard. He is going to divide the orchard into two parts, sell the first one and keep the other one.

The trees were originally planted in regular rows and columns forming a rectangular grid with the same number of rows and columns. As years went by, Oliver removed many trees which were weak or plagued by bugs so nowadays there is also a lot of free squares unoccupied by any tree.

Oliver has decided that he will keep exactly half of all the trees in the orchard. Moreover, he has few additional demands which, in his opinion, will ensure easy maintenance of his part in the future.

  • The part Oliver is going to keep should be in the shape of a rectangle.
  • A least one corner of the rectangle should coincide with a corner of the orchard.
  • The rectangle area should be as small as possible.

Originally, each tree was planted in the center of an imaginary square whose area was exactly one square meter. Thus, the position of each tree can be described by the coordinates of the square on which it is standing. The dividing fence between the two parts of the orchard will run along the borders of the squares.

입력

There are more test cases. Each case starts with a line containing two integers M (1 ≤ M ≤ 109 ) and N (1 ≤ N ≤ 106 ) separated by space. The orchard side length in meters is expressed by M and the number of trees in the orchard is expressed by N. Next, there are N lines, each line specifies x and y coordinates of one tree in the orchard. The coordinates are separated by space. For simplicity reasons, we assume that the coordinates are zero based, so the coordinates of the squares in the corners of the orchard are (0, 0),(0, M − 1),(M − 1, M − 1),(M − 1, 0). All coordinate pairs (x, y) in one test case are unique.

출력

For each test case, print a single line with one whole number A denoting the minimum possible area in square meters of uncle Oliver’s part of the orchard. If it is not possible to divide the orchard according to Oliver’s demands print “-1”. Note that the output value might not fit into 32-bit integer type.

제한

예제 입력 1

6 8
4 5
1 4
0 3
5 3
1 2
3 2
3 1
2 0
3 3
2 0
1 1
0 2
2 2
0 0
1 1

예제 출력 1

12
-1
1

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CTU Open Contest > CTU Open Contest 2016 O번

Contest > Open Cup > 2016/2017 Season > Stage 6: Czech Grand Prix D번

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

출처

대학교 대회

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

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