CF595A.Vitaly and Night

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.

Vitaly sees a building of n floors and 2·m windows on each floor. On each floor there are m flats numbered from 1 to m, and two consecutive windows correspond to each flat. If we number the windows from 1 to 2·m from left to right, then the j-th flat of the i-th floor has windows 2·j - 1 and 2·j in the corresponding row of windows (as usual, floors are enumerated from the bottom). Vitaly thinks that people in the flat aren't sleeping at that moment if at least one of the windows corresponding to this flat has lights on.

Given the information about the windows of the given house, your task is to calculate the number of flats where, according to Vitaly, people aren't sleeping.

一天,维塔利深夜回家时突然想到:此时此刻,究竟有多少人还没睡觉?为了估算这个数字,维塔利决定观察他路过的那栋楼里哪些窗户亮着灯。

维塔利看到一栋有 nn 层的楼房,每层有 2⋅m2\cdot m 扇窗户。每层楼有 mm 套公寓,编号从 11 到 mm,每套公寓对应两扇相邻的窗户。若将每层的窗户从左到右编号为 11 到 2⋅m2\cdot m,则第 ii 层(按常规,楼层从底层开始编号)的第 jj 套公寓对应的窗户为该层窗户序列中的第 2⋅j−12\cdot j - 1 扇和第 2⋅j2\cdot j 扇。维塔利认为:若某套公寓对应的两扇窗户中至少有一扇亮着灯,则该公寓内的人此时没有睡觉。

现给出该楼房各扇窗户的亮灯情况,请你计算出:按照维塔利的判断,此时没有睡觉的人所在的公寓总数。

输入格式

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100) — the number of floors in the house and the number of flats on each floor respectively.

Next n lines describe the floors from top to bottom and contain 2·m characters each. If the i-th window of the given floor has lights on, then the i-th character of this line is '1', otherwise it is '0'.

输入的第一行包含两个整数 nn 和 mm(1 ≤ n, m ≤ 1001 ≤ n, m ≤ 100)—— 分别表示楼房的楼层数和每层的公寓数。

接下来的 nn 行从上到下描述各楼层,每行包含 2⋅m2·m 个字符。若给定楼层的第 ii 扇窗户亮着灯,则该行的第 ii 个字符为 '1',否则为 '0'。

输出格式

Print a single integer — the number of flats that have lights on in at least one window, that is, the flats where, according to Vitaly, people aren't sleeping.

输出一个整数——至少有一扇窗户亮着灯的公寓数量,即根据维塔利的说法,人们没有在睡觉的公寓数量。

输入输出样例

  • 输入#1

    2 2
    0 0 0 1
    1 0 1 1

    输出#1

    3
  • 输入#2

    1 3
    1 1 0 1 0 0

    输出#2

    2

说明/提示

In the first test case the house has two floors, two flats on each floor. That is, in total there are 4 flats. The light isn't on only on the second floor in the left flat. That is, in both rooms of the flat the light is off.

In the second test case the house has one floor and the first floor has three flats. The light is on in the leftmost flat (in both windows) and in the middle flat (in one window). In the right flat the light is off.

在第一个测试用例中,该住宅有两层楼,每层楼有两个公寓。也就是说,总共有 4 个公寓。仅有第二层左侧公寓的灯是关闭的。也就是说,该公寓的两个房间内的灯均处于关闭状态。

在第二个测试用例中,该住宅只有一层楼,且该层楼有三个公寓。最左侧公寓(两个窗户)的灯是开启的,中间公寓(一个窗户)的灯是开启的,而最右侧公寓的灯是关闭的。

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

首页