Codeforces Round #330 (Div. 2) A. Vitaly and Night 暴力
2015-11-09 09:06
344 查看
[b]A. Vitaly and Night[/b]
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
http://codeforces.com/contest/595/problem/ADescription
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.
Under two situations the player could score one point.
⋅1. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won't get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.
⋅2. Ignoring the buoys and relying on dogfighting to get point.
If you and your opponent meet in the same position, you can try to
fight with your opponent to score one point. For the proposal of game
balance, two players are not allowed to fight before buoy #2 is touched by anybody.
There are three types of players.
Speeder:
As a player specializing in high speed movement, he/she tries to avoid
dogfighting while attempting to gain points by touching buoys.
Fighter:
As a player specializing in dogfighting, he/she always tries to fight
with the opponent to score points. Since a fighter is slower than a
speeder, it's difficult for him/her to score points by touching buoys
when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.
There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.
Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting.
Since Asuka is slower than Shion, she decides to fight with Shion for
only one time during the match. It is also assumed that if Asuka and
Shion touch the buoy in the same time, the point will be given to Asuka
and Asuka could also fight with Shion at the buoy. We assume that in
such scenario, the dogfighting must happen after the buoy is touched by
Asuka or Shion.
The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?
[b]Input[/b]
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'.
[b]Output[/b]
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.
[b]Sample Input[/b]
2 2 0 0 0 1 1 0 1 1
[b]Sample Output[/b]
3
HINT
[b]题意[/b]
有一个n行m列的房子,每个人有两个窗户,然后有人想知道这栋楼究竟有多少个人没有睡觉
如果两个窗户中至少有一个亮着,就说明没有睡
[b]题解:[/b]
直接暴力for一遍就好了
[b]代码[/b]
#include<iostream> #include<stdio.h> using namespace std; int n,m; int main() { scanf("%d%d",&n,&m); int ans=0,x,y; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%d%d",&x,&y); if(x||y) ans++; } } printf("%d\n",ans); }
相关文章推荐
- maven下的ssm整合配置步骤
- RHCE 系列(六):安装 Samba 并配置 Firewalld 和 SELinux,和 Windows 共享文件
- 当将Activity的主题Theme设置为Dialog,控制Activity的位置
- UI学习之常用方法
- 根据focus状态改变颜色
- 【eclipse rcp开发】插件内部文件读写方法
- Java—面向对象
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
- IO的五种模型
- chown命令
- 知识链-数据结构
- 你真的会玩SQL吗?你所不知道的 数据聚合
- 五种常见的 PHP 设计模式
- 第一次学习写博客。有些激动,希望自己的总结能够帮助到别人,也希望自己日后总结时能够做到提醒自己。
- windows下实现oracle自动备份 bat
- keil 中——C语言模块化编程时全局变量、结构体的定义、声明以及头文件包含的处理方法
- c语言实现封装、继承和多态
- 序列化--反序列化:Schema evolution in Avro, Protocol Buffers and Thrift
- openSUSE Leap 42.1 华丽发布
- Spring MVC请求转发和重定向