CF413B.Spyke Chatting

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

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.

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.

R2 公司共有 nn 名员工。工作过程中需要持续交流想法、分享成功经验以及即将到来的挑战。为此,R2 使用一款著名的即时通讯软件 Spyke。

R2 共有 mm 个 Spyke 聊天群组,用于讨论各类问题。在每个聊天群组中,均有若干员工每日进行消息交流。一名员工可同时参与多个聊天群组。若某员工加入了第 kk 个聊天群组,则他可以向该群组发送消息,并接收来自该群组的消息通知。当某员工在某个聊天群组中发送一条消息时,该群组中所有其他参与者均会收到一条消息通知。

R2 公司正在进行一项审计工作。目前,审计专家正研究员工之间沟通的有效性。为此,他们已获取一份聊天日志及聊天群组结构描述。你作为审计专家之一,受委托编写一个程序,利用这些数据计算每名员工所收到的消息通知总数。

输入格式

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.

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.

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.

第一行包含三个以空格分隔的整数 nn、mm 和 kk(2 ≤ n ≤ 2⋅1042 \leq n \leq 2\cdot10^4;1 ≤ m ≤ 101 \leq m \leq 10;1 ≤ k ≤ 2⋅1051 \leq k \leq 2\cdot10^5),分别表示员工人数、聊天室数量以及日志中事件的数量。

接下来的 nn 行描述一个大小为 n × mn \times m 的矩阵 aa,其中仅包含数字 00 和 11。该矩阵中第 ii 行第 jj 列的元素(记作 aija_{ij})等于 11,当且仅当第 ii 号员工是第 jj 号聊天室的参与者;否则该元素为 00。假设员工编号为 11 至 nn,聊天室编号为 11 至 mm。

接下来的 kk 行描述日志中的事件。第 ii 行包含两个以空格分隔的整数 xix_i 和 yiy_i(1 ≤ xi ≤ n1 \leq x_i \leq n;1 ≤ yi ≤ m1 \leq y_i \leq m),表示编号为 xix_i 的员工向编号为 yiy_i 的聊天室发送了一条消息。保证编号为 xix_i 的员工确实是聊天室 yiy_i 的参与者。还保证每个聊天室至少包含两名员工。

输出格式

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.

在一行中输出 n 个以空格分隔的整数,其中第 i 个整数表示第 i 位员工收到的消息通知数量。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页