5-26 Population(35분) - 해결 예정

5-26 Population(35분)
It is always exciting to see people settling in a new continent. As the head of the population management office, you are supposed to know, at any time, how people are distributed in this continent.
The continent is divided into square regions, each has a center with integer coordinates (x,y). Hence all the people coming into that region are considered to be settled at the center position. Given the positions of the corners of a rectangle region, you are supposed to count the number of people living in that region.

Input Specification:


Each input file contains one test case. For each case, the character  I  in a line signals the coming in of new groups of people. In the following lines, each line contains three integers:  XY , and  N , where  X and  Y  (1 ≤  XY  ≤ 20000) are the coordinates of the region's center, and  N  (1 ≤  N  ≤ 10000) is the number of people coming in.
The character  Q  in a line signals the query of population. The following lines each contains four numbers: X​min​​, X​max​​, Y​min​​, Y​max​​, where (X​min​​,Y​min​​) and (X​max​​,Y​max​​) are the integer coordinates of the lower left corner and the upper right corner of the rectangle, respectively.
The character  E  signals the end of the test case.

Output Specification:


For each  Q  case, print in a line the population in the given rectangle region. That is, you are supposed to count the number of people living at all the positions (x,y) such that X​min​​≤x≤X​max​​, and Y​min​​≤y≤Y​max​​.

Sample Input:

I
8 20 1
4 5 1
10 11 1
12 10 1
18 14 1
Q
8 10 5 15
8 20 10 14
I
7 6 1
10 3 2
7 2 1
2 3 2
10 3 1
Q
2 20 2 20
E

Sample Output:

1
3
12

 
  • 시간제한: 600ms
  • 메모리 제한: 64MB
  • 코드 길이 제한: 16kB
  • 판정 프로그램: 시스템 기본값

  • .작가: 진월
    .단위: 절강대학

    좋은 웹페이지 즐겨찾기