CF413B.Spyke Chatting

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The R2 company has nn 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.

R2 has mm 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 kk -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.

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.

输入格式

The first line contains three space-separated integers nn , mm and kk (2<=n<=2104; 1<=m<=10; 1<=k<=2105)(2<=n<=2·10^{4}; 1<=m<=10; 1<=k<=2·10^{5}) — the number of the employees, the number of chats and the number of events in the log, correspondingly.

Next nn lines contain matrix aa of size n×mn×m , consisting of numbers zero and one. The element of this matrix, recorded in the jj -th column of the ii -th line, (let's denote it as aija_{ij} ) equals 11 , if the ii -th employee is the participant of the jj -th chat, otherwise the element equals 00 . Assume that the employees are numbered from 11 to nn and the chats are numbered from 11 to mm .

Next kk lines contain the description of the log events. The ii -th line contains two space-separated integers xix_{i} and yiy_{i} (1<=xi<=n; 1<=yi<=m)(1<=x_{i}<=n; 1<=y_{i}<=m) which mean that the employee number xix_{i} sent one message to chat number yiy_{i} . It is guaranteed that employee number xix_{i} is a participant of chat yiy_{i} . It is guaranteed that each chat contains at least two employees.

输出格式

Print in the single line nn space-separated integers, where the ii -th integer shows the number of message notifications the ii -th employee receives.

输入输出样例

  • 输入#1

    3 4 5
    1 1 1 1
    1 0 1 1
    1 1 0 0
    1 1
    3 1
    1 3
    2 4
    3 2
    

    输出#1

    3 3 1 
  • 输入#2

    4 3 4
    0 1 1
    1 0 1
    1 1 1
    0 0 0
    1 2
    2 1
    3 1
    1 3
    

    输出#2

    0 2 3 0 
首页