codeforces-scrape

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

52B.md (1051B)


      1 Source: https://codeforces.com/problemset/problem/52/B
      2 
      3 B. Right Triangles
      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 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 You are given a *n* × *m* field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle).
     22 
     23 Input
     24 
     25 The first line contains two positive integer numbers *n* and *m* (1 ≤ *n*, *m* ≤ 1000). The following *n* lines consist of *m* characters each, describing the field. Only '.' and '*' are allowed.
     26 
     27 Output
     28 
     29 Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 2 2  
     37 **  
     38 *.
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 1
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 3 4  
     51 *..*  
     52 .**.  
     53 *.**
     54 ```
     55 
     56 Output
     57 
     58 ```
     59 9
     60 ```