Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
VBOARD - Chessboard |
English | Vietnamese |
Given a chessboard of size nxn. There is a number in each square of the board. The top-left square is in white color (the squares are in black and white color alternatively). The columns are numbered as 1 to n from left to right. The rows are number as 1 to n from top to bottom. The square in the ith row and jth column of the board is denoted as (i, j).
Cuoi have some puzzles for Bom: Cuoi tells Bom a rectangle area in the chessboard, and Bom has to calculate the absolute value of the difference between the sum of white squares' numbers and the sum of black squares' numbers in that area. Help Bom to answer these puzzles.
Input
- The first line contains an integer n (1 ≤ n ≤ 500).
- The ith line in the next n lines contains n integers ai1, ai2, ..., aij representing the numbers in the ith row of the chessboard (0 ≤ aij < 100).
- The (n+2)th row contains an integer q that is the number of Cuoi's puzzles (1 ≤ q ≤ 10000).
- Each line in the next q lines contains four integers i1, j1, i2, j2 representing the coordinates of a rectangle area in a puzzle: the top -left corner is (i1, j1) and the bottom-right corner is (i2, j2).
Output
Print out q lines; in each line, print Bom's answer to Cuoi's corresponding puzzle.
Constraint
There are 50% of the test cases corresponding to 50% of the grades in which 1 ≤ n ≤ 100 and 1 ≤ q ≤ 2000.
Example
Input 3 1 3 5 2 4 6 0 10 5 2 1 1 2 2 1 2 3 3 Output 0 5
Được gửi lên bởi: | Jimmy |
Ngày: | 2008-06-18 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET |
Nguồn bài: | VNOI Marathon '08 - Round 2/DivB Problem Setter: Ngô Minh Đức |
hide comments
|
||||||
2021-02-15 12:05:50
Code AC: https://ideone.com/ZUMz0e (fpc 3.0.4). Last edit: 2021-02-15 13:09:31 |
||||||
2021-02-15 09:29:50
O(n^2) AC. ez!!! Last edit: 2021-02-15 13:11:31 |
||||||
2019-01-07 16:37:59
Gọn nhẹ vài dòng 1 đấm AC frostpixel aka.How 2 AC |
||||||
2018-02-03 16:54:01
solution: http://123link.pw/1dBl5 code http://123link.pw/pOvqL |
||||||
2017-09-25 17:24:38
1 đấm ac nhoé :) cda.dev |
||||||
2016-01-10 10:51:26
1 tát AC :v :v :v |
||||||
2015-12-13 08:38:49 The Flash
:3 Bonus :v 1 đấm |
||||||
2015-12-12 11:13:02
THAM KHẢO TẠI https://traitaodo.wordpress.com/2015/09/16/chessboard-vboard/ |
||||||
2015-12-06 14:15:17
cứ 0s 0mem là bị gì nhỉ?? |
||||||
2015-11-04 13:29:08
1 hit AC :)) chỉ là xử lí đơn giản |