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. android中ListView_SimpleAdapter

    1.首先看下main_activity.xml.其实里面就放了一个ListView. <LinearLayout xmlns:android="http://schemas.andro ...

  2. C++ code: 将程序的输出,保存到txt文档中,且每35个数,自动换行

    // write the predicted score into txt files       ofstream file("/home/wangxiao/Downloads/caffe ...

  3. Machine Learning and Data Science 教授大师

    http://www.cs.cmu.edu/~avrim/courses.html Foundations of Data Science Avrim Blum, www.cs.cornell.edu ...

  4. SyntaxError: Non-ASCII character '\xe6'

    这是编码的问题,在文件第一行加上如下命令即可: #encoding: utf-8

  5. Java实现一个字符串的反转

    Java小程序实现字符串的反转: 方法一: public class reverseString { public static void main(String[] args) { String s ...

  6. Python学习笔记——文件

    1.文件只是连续的字节序列 open()内建函数是打开文件之门的钥匙 file_obj=open(file_name,access_mode='r/w/a,' buffering=-1) file_n ...

  7. add to svn ignore disabled

    The problem is that the folder is already under version control. Here's how I fix this type of probl ...

  8. Java C# 加密解密类库

    Bouncy Castle 是一种用于 Java 平台的开放源码的轻量级密码术包.它支持大量的密码术算法,并提供 JCE 1.2.1 的实现.因为 Bouncy Castle 被设计成轻量级的,所以从 ...

  9. WebAPI Post类型传参报错“找不到与该请求匹配的操作”

    错误内容: Message=未找到与请求 URI“http://localhost:42914/api/Products/Login”匹配的 HTTP 资源. MessageDetail=在控制器“P ...

  10. 关于ExpandableListView用法的一个简单小例子

    喜欢显示好友QQ那样的列表,可以展开,可以收起,在android中,以往用的比较多的是listview,虽然可以实现列表的展示,但在某些情况下,我们还是希望用到可以分组并实现收缩的列表,那就要用到an ...