codeforces-scrape

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

413B.md (2653B)


      1 Source: https://codeforces.com/problemset/problem/413/B
      2 
      3 B. Spyke Chatting
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 The R2 company has *n* employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.
     22 
     23 R2 has *m* Spyke chats just to discuss all sorts of issues. In each chat, some group of employees exchanges messages daily. An employee can simultaneously talk in multiple chats. If some employee is in the *k*-th chat, he can write messages to this chat and receive notifications about messages from this chat. If an employee writes a message in the chat, all other participants of the chat receive a message notification.
     24 
     25 The R2 company is conducting an audit. Now the specialists study effective communication between the employees. For this purpose, they have a chat log and the description of chat structure. You, as one of audit specialists, are commissioned to write a program that will use this data to determine the total number of message notifications received by each employee.
     26 
     27 Input
     28 
     29 The first line contains three space-separated integers *n*, *m* and *k* (2 ≤ *n* ≤ 2·104; 1 ≤ *m* ≤ 10; 1 ≤ *k* ≤ 2·105) — the number of the employees, the number of chats and the number of events in the log, correspondingly.
     30 
     31 Next *n* lines contain matrix *a* of size *n* × *m*, consisting of numbers zero and one. The element of this matrix, recorded in the *j*-th column of the *i*-th line, (let's denote it as *a**ij*) equals 1, if the *i*-th employee is the participant of the *j*-th chat, otherwise the element equals 0. Assume that the employees are numbered from 1 to *n* and the chats are numbered from 1 to *m*.
     32 
     33 Next *k* lines contain the description of the log events. The *i*-th line contains two space-separated integers *x**i* and *y**i* (1 ≤ *x**i* ≤ *n*; 1 ≤ *y**i* ≤ *m*) which mean that the employee number *x**i* sent one message to chat number *y**i*. It is guaranteed that employee number *x**i* is a participant of chat *y**i*. It is guaranteed that each chat contains at least two employees.
     34 
     35 Output
     36 
     37 Print in the single line *n* space-separated integers, where the *i*-th integer shows the number of message notifications the *i*-th employee receives.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3 4 5  
     45 1 1 1 1  
     46 1 0 1 1  
     47 1 1 0 0  
     48 1 1  
     49 3 1  
     50 1 3  
     51 2 4  
     52 3 2
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 3 3 1
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 4 3 4  
     65 0 1 1  
     66 1 0 1  
     67 1 1 1  
     68 0 0 0  
     69 1 2  
     70 2 1  
     71 3 1  
     72 1 3
     73 ```
     74 
     75 Output
     76 
     77 ```
     78 0 2 3 0
     79 ```