codeforces-scrape

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

635A.md (2062B)


      1 Source: https://codeforces.com/problemset/problem/635/A
      2 
      3 A. Orchestra
      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 Paul is at the orchestra. The string section is arranged in an *r* × *c* rectangular grid and is filled with violinists with the exception of *n* violists. Paul really likes violas, so he would like to take a picture including at least *k* of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count the number of possible pictures that Paul can take.
     22 
     23 Two pictures are considered to be different if the coordinates of corresponding rectangles are different.
     24 
     25 Input
     26 
     27 The first line of input contains four space-separated integers *r*, *c*, *n*, *k* (1 ≤ *r*, *c*, *n* ≤ 10, 1 ≤ *k* ≤ *n*) — the number of rows and columns of the string section, the total number of violas, and the minimum number of violas Paul would like in his photograph, respectively.
     28 
     29 The next *n* lines each contain two integers *x**i* and *y**i* (1 ≤ *x**i* ≤ *r*, 1 ≤ *y**i* ≤ *c*): the position of the *i*-th viola. It is guaranteed that no location appears more than once in the input.
     30 
     31 Output
     32 
     33 Print a single integer — the number of photographs Paul can take which include at least *k* violas.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 2 2 1 1  
     41 1 2
     42 ```
     43 
     44 Output
     45 
     46 ```
     47 4
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 3 2 3 3  
     54 1 1  
     55 3 1  
     56 2 2
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 1
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 3 2 3 2  
     69 1 1  
     70 3 1  
     71 2 2
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 4
     78 ```
     79 
     80 Note
     81 
     82 We will use '*' to denote violinists and '#' to denote violists.
     83 
     84 In the first sample, the orchestra looks as follows
     85 
     86 ```
     87 *#  
     88 **
     89 ```
     90 
     91 Paul can take a photograph of just the viola, the 1 × 2 column containing the viola, the 2 × 1 row containing the viola, or the entire string section, for 4 pictures total.
     92 
     93 In the second sample, the orchestra looks as follows
     94 
     95 ```
     96 #*  
     97 *#  
     98 #*
     99 ```
    100 
    101 Paul must take a photograph of the entire section.
    102 
    103 In the third sample, the orchestra looks the same as in the second sample.