ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

LaunchPad

2020-01-19 21:02:29  阅读:355  来源: 互联网

标签:square LaunchPad int leq touch squares


链接: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=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}
typedef long long ll;
const int maxn=1e4+10;
const int M=1e7+10;
const int INF=0x3f3f3f3f;
int vis[1010][1010];
int h[maxn];//行 
int l[maxn];//列 
int main()
{
    int n,m,t; 
    cin>>n>>m>>t;
    int a,b;
    for(int i=0;i<t;i++){
        cin>>a>>b;
        h[a]++;
        l[b]++;
        vis[a][b]++;
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if((h[i]+l[j]-vis[i][j])%2==1){
                sum++;
            }
        }
    }
    printf("%d",sum);
    return 0;
}

 

 

标签:square,LaunchPad,int,leq,touch,squares
来源: https://www.cnblogs.com/lipu123/p/12215556.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有