Cells Not Under Attack

题意:

给出n*n的地图,有给你m个坐标,是棋子,一个棋子可以把一行一列都攻击到,在根据下面的图,就可以看出让你求阴影(即没有被攻击)的方块个数

题解:

我先是认真的看了前面之后,发现看不懂,最后一看图,就明白了,这就似乎证明了图片已经超越了语言,MD 扯远了。

这题要这么想,增加了一个点,就要减少一行一列,之后再把他们拼到一起,之后发现也就是求x*y了(x是行没有出现的个数,y是列没有出现的个数) 还有就是要注意这题是longlong,又被ll坑了 = =

代码:

#include <iostream>
#include<set>
#include<cstdio>
#include<vector>
using namespace std; int main()
{
int n,m;
cin>>n>>m;
set<int> a;
set<int> b;
vector<long long> ans;
for (int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
a.insert(x);
b.insert(y);
ans.push_back((long long )(n-a.size())*(n-b.size()));
}
int d=ans.size();
for (int i=0;i<d;i++) printf("%I64d%c",ans[i],i==d-1?'\n':' ');
return 0;
}

Codeforces Round #364 (Div. 2) Cells Not Under Attack的更多相关文章

  1. Codeforces Round #364 (Div. 2) B. Cells Not Under Attack

    B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. Codeforces Round #364 (Div. 2) B 标记

    B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  3. Codeforces Round #364 (Div. 2),只有A与B

    A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  4. Codeforces Round #364 (Div. 2)

    这场是午夜场,发现学长们都睡了,改主意不打了,第二天起来打的virtual contest. A题 http://codeforces.com/problemset/problem/701/A 巨水无 ...

  5. Codeforces Round #364 (Div.2) D:As Fast As Possible(模拟+推公式)

    题目链接:http://codeforces.com/contest/701/problem/D 题意: 给出n个学生和能载k个学生的车,速度分别为v1,v2,需要走一段旅程长为l,每个学生只能搭一次 ...

  6. Codeforces Round #364 (Div.2) C:They Are Everywhere(双指针/尺取法)

    题目链接: http://codeforces.com/contest/701/problem/C 题意: 给出一个长度为n的字符串,要我们找出最小的子字符串包含所有的不同字符. 分析: 1.尺取法, ...

  7. 树形dp Codeforces Round #364 (Div. 1)B

    http://codeforces.com/problemset/problem/700/B 题目大意:给你一棵树,给你k个树上的点对.找到k/2个点对,使它在树上的距离最远.问,最大距离是多少? 思 ...

  8. Codeforces Round #364 (Div. 2) B

    Description Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is e ...

  9. Codeforces Round #364 (Div. 2) Cards

    Cards 题意: 给你n个牌,n是偶数,要你把这些牌分给n/2个人,并且让每个人的牌加起来相等. 题解: 这题我做的时候,最先想到的是模拟,之后码了一会,发现有些麻烦,就想别的方法.之后发现只要把它 ...

随机推荐

  1. HTML DOM参考手册

    HTML DOM是HTML Document Object Model(文档对象模型)的缩写,HTML DOM则是专门适用与HTML/XHTML的文档对象模型.熟悉软件开发的人员可以将HTML DOM ...

  2. Visual C++ 设置适合自己的解决方案目录结构

    Visual C++ 使用解决方案来管理项目,项目之间还可能有依赖关系,设置适合自己的解决方案目录结构,便于代码的管理.程序的发布. 下面开始一个虚拟解决方案设计:         假设此解决方案有应 ...

  3. Oracle Enterprise Manager Cloud Control 12c的安装

    这里,我介绍的是Cloud Control 12c的安装.之前的版本叫Grid Control,这也是11g里面的叫法.在我写这篇博客时,Cloud Control 13c已经出来了,这个版本后续我再 ...

  4. Hive 安装配置记录

    http://yymmiinngg.iteye.com/blog/708230 export HADOOP_HOME_WARN_SUPPRESS=1 export JAVA_HOME=/home/ha ...

  5. linux知识点

    通过gui来使用通过api来使用通过cli来使用通过tui来使用 进程不在,但tcp连接还一直存在的解决办法--tcpkill命令 http://www.centoscn.com/CentOS/Int ...

  6. python图像识别--验证码

    1.pip3 install pyocr 2.pip3 install pillow or easy_install Pillow 3.安装tesseract-ocr:http://jaist.dl. ...

  7. TKinter的常用组件

    python提供了多个图形开发界面的库,几个常用Python GUI库如下: Tkinter: Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.T ...

  8. 浅析Struts1和Struts2的Action线程安全问题 转

    浅析Struts1和Struts2的Action线程安全问题  转 http://blog.csdn.net/virgoboy2004/article/details/5876133 [问题描述]最近 ...

  9. Js数组去重复取唯一值

    function isBigEnough(element) { return element >= 10; } var filtered = [12, 5, 8, 130, 44].filter ...

  10. 解压jar

    unzip EtnetChinaApplication.jar -d app进入临时目录app,编辑文件