链接:https://ac.nowcoder.com/acm/contest/3665/D
来源:牛客网

Hery is a boy with strong practical abilities. Nowadays,he designed a LaunchPad which is not same as what you ever seen.
The LaunchPad is a touch screen divided into squares of N rows and M columns. Each square has two states of light and shade. And all squares are shady initially. When you touch the square in row X and column Y, the state of all the squares in the row and column will change. Now he wants to know how many squares are light on the LaunchPad after he makes multiple touches.

输入描述:

The first line of input contains two integers N,M(1≤N,M≤1000)N,M (1\leq N,M\leq 1000)N,M(1≤N,M≤1000) denoting the rows and columns of LaunchPad.
The second line of input contains single integer Q(0≤Q≤106)Q (0\leq Q\leq 10^6)Q(0≤Q≤106) denoting the times of touch.
On the next Q lines,describe X and Y - the position of the square being touched. (1≤X≤N,1≤Y≤M)(1\leq X \leq N,1\leq Y\leq M)(1≤X≤N,1≤Y≤M)

输出描述:

Print one line - the number of the squares that is on light state.
示例1

输入

复制

1 1
1
1 1

输出

复制

1
示例2

输入

复制

2 4
2
2 4
1 4

输出

复制

6

说明

题目大意:

就是说一开始n*m矩阵中都是暗的,你可以按压n*m矩阵中任意一个方格,该方格行和列都会变亮,再摁一次会变暗,问m次操作后亮的方格的个数;

解析:

就是行和列的性质不变,但是vis[a][b]会重复

AC代码:

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
inline int read() {int x=,f=;char c=getchar();while(c!='-'&&(c<''||c>''))c=getchar();if(c=='-')f=-,c=getchar();while(c>=''&&c<='')x=x*+c-'',c=getchar();return f*x;}
typedef long long ll;
const int maxn=1e4+;
const int M=1e7+;
const int INF=0x3f3f3f3f;
int vis[][];
int h[maxn];//行
int l[maxn];//列
int main()
{
int n,m,t;
cin>>n>>m>>t;
int a,b;
for(int i=;i<t;i++){
cin>>a>>b;
h[a]++;
l[b]++;
vis[a][b]++;
}
int sum=;
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
if((h[i]+l[j]-vis[i][j])%==){
sum++;
}
}
}
printf("%d",sum);
return ;
}

LaunchPad的更多相关文章

  1. Launchpad添加openPGP keys

    转自: https://help.ubuntu.com/community/GnuPrivacyGuardHowto mac下: http://notes.jerzygangi.com/the-bes ...

  2. 应用删除后 Launchpad 上仍有应用图标无法删除的解决方法

    应用删除后 Launchpad 上仍有应用图标上带有问号且无法删除时,可以将 launchpad 重置. 在终端输入: defaults write com.apple.dock ResetLaunc ...

  3. window bzr launchpad 安装配置

    1: https://launchpad.net/bzr/2.6/2.6b1/+download/bzr-2.6b1-1-setup.exe 使用Standalone版本  , 安装时选择plugin ...

  4. CCS v5 无法启动解决办法及Launchpad仿真器电脑无法识别解决方法

    安装ccs_setup_5.1.1.00028.exe后(无论是自己装eclipse还是在原来的基础上安装eclipse的插件),ccs5的应用无法打开,错误为:An error has occurr ...

  5. osx launchpad删除图标

    安装了个parallels desktop之后,OSX中的launchpad中的图标多了不少,但是好多都不是我自己想要的,我们该怎么删除或者改动呢,以下介绍一些方法: ①直接操作Appications ...

  6. Launchpad灰色图标怎么删除?重置Launchpad教程

    打开终端,第一步输入:defaults write com.apple.dock ResetLaunchPad -bool true 按下return键 第二步输入:killall Dock 按下re ...

  7. MAC 调整Launchpad 图标大小

    1.调整每一列显示图标数量 defaults write com.apple.dock springboard-rows -int 7 2.调整每一行显示图标数量 defaults write com ...

  8. Ubuntu 16.04系统下出现E: 无法下载 http://ppa.launchpad.net/fcitx-team/nightly/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found

    在安装完成Chrome浏览器后,终端执行以下更新命令 sudo apt-get update 时出现E: 无法下载 http://ppa.launchpad.net/fcitx-team/nightl ...

  9. 解决 Mac launchpad 启动台 Gitter 图标无法删除的问题

    Mac 删除应用非常简单,将应用拖到回收站就删除了.或者进入应用程序文件夹,选中程序,command + delete 就删除了应用,这也是删除文件的快捷键. 但是,安装 Gitter 后,删除了应用 ...

  10. 解决Mac应用程序软件不出现在Launchpad里面的方法

    新装了几个软件,可是打开Lauchpad之后却在里面找不到,真是烦人!然后尝试了以下方法: 1.重启电脑,没用: 2.尝试打开“应用程序(英文名称:Applications)”并找到安装的软件,然后直 ...

随机推荐

  1. EF简单的CodeFirst示例(自己创建数据库,不使用数据迁移)

    1.新建一个控制台应用程序 2.右键引用--管理NuGet程序包,安装如下几项 3.打开App.config文件,加入如下代码: <connectionStrings>    <ad ...

  2. mysql 低版本导入表中包含两个TIMESTAMP报错问题

    错误代码: 1293  Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAM ...

  3. Mapper-元素和属性

    Mapper.xml文件内部的元素和属性     parameterType(输入类型) §  传递简单类型 §  使用#{}占位符,或者${}进行sql拼接, #{}括号中的值可以任意, ${}括号 ...

  4. 返回一条最近一次cURL操作明确的文本的错误信息。

    参考:https://www.runoob.com/php/func-curl_error.html <?php // 创建一个指向一个不存在的位置的cURL句柄 $ch = curl_init ...

  5. JQ 获取浏览器窗口宽高

    $(window).height(); // 浏览器时下窗口可视区域高度 $(document).height(); //浏览器时下窗口文档的高度 $(document.body).height(); ...

  6. web-css-文本

    一.文本的水平对齐方式 使用text-align来设置文本的对齐方式:text-align的取值:left(向左对齐)/center(水平居中对齐)/right(向右对齐)/justify(两端对齐) ...

  7. Failed to start mysqld.service: Unit not found

    输入命令 systemctl start mysql.service 要启动MySQL数据库是却是这样的提示 Failed to start mysqld.service: Unit not foun ...

  8. 在Linux系统下安装jdk并配置环境变量

    本文主要介绍的是如何是Linux环境下安装JDK的,因为Linux环境下,很多时候也离不开Java的,下面笔者就和大家一起分享如何jdk1.8的过程吧. 1.安装环境 操作系统:CentOS 07 6 ...

  9. (c#)奇数值单元格的数量

    题目 解

  10. codeforces 962F.simple cycle(tarjan/点双连通分量)

    题目连接:http://codeforces.com/contest/962/problem/F 题目大意是定义一个simple cycle为从一个节点开始绕环走一遍能经过simple cycle内任 ...