codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

552A.md (1781B)


      1 Source: https://codeforces.com/problemset/problem/552/A
      2 
      3 A. Vanya and Table
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.
     22 
     23 In this table, Vanya chose *n* rectangles with sides that go along borders of squares (some rectangles probably occur multiple times). After that for each cell of the table he counted the number of rectangles it belongs to and wrote this number into it. Now he wants to find the sum of values in all cells of the table and as the table is too large, he asks you to help him find the result.
     24 
     25 Input
     26 
     27 The first line contains integer *n* (1 ≤ *n* ≤ 100) — the number of rectangles.
     28 
     29 Each of the following *n* lines contains four integers *x*1, *y*1, *x*2, *y*2 (1 ≤ *x*1 ≤ *x*2 ≤ 100, 1 ≤ *y*1 ≤ *y*2 ≤ 100), where *x*1 and *y*1 are the number of the column and row of the lower left cell and *x*2 and *y*2 are the number of the column and row of the upper right cell of a rectangle.
     30 
     31 Output
     32 
     33 In a single line print the sum of all values in the cells of the table.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 2  
     41 1 1 2 3  
     42 2 2 3 3
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 10
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 2  
     55 1 1 3 3  
     56 1 1 3 3
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 18
     63 ```
     64 
     65 Note
     66 
     67 Note to the first sample test:
     68 
     69 Values of the table in the first three rows and columns will be as follows:
     70 
     71 121
     72 
     73 121
     74 
     75 110
     76 
     77 So, the sum of values will be equal to 10.
     78 
     79 Note to the second sample test:
     80 
     81 Values of the table in the first three rows and columns will be as follows:
     82 
     83 222
     84 
     85 222
     86 
     87 222
     88 
     89 So, the sum of values will be equal to 18.