zoukankan      html  css  js  c++  java
  • Codeforces Round #330 (Div. 2) A. Vitaly and Night 暴力

    A. Vitaly and Night

    Time Limit: 20 Sec

    Memory Limit: 256 MB

    题目连接

    http://codeforces.com/contest/595/problem/A

    Description

    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 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 m from left to right, then the j-th flat of the i-th floor has windows j - 1 and 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)?

    Input

    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 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'.

    Output

    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.

    Sample Input

    2 2
    0 0 0 1
    1 0 1 1

    Sample Output

    3

    HINT

    题意

     有一个n行m列的房子,每个人有两个窗户,然后有人想知道这栋楼究竟有多少个人没有睡觉

    如果两个窗户中至少有一个亮着,就说明没有睡

    题解:

    直接暴力for一遍就好了

    代码

    #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
    ",ans);
    }
  • 相关阅读:
    velocity .vm
    @Autowired
    springMVC
    索引
    Adivisor
    计算火车运行的时间
    倒三角
    XML简介
    表单提交方式
    js动态生成表格
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4948985.html
Copyright © 2011-2022 走看看