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. Kerberos的基本概念

    1.Princal(安全个体):被认证的个体,有一个名字和口令.(客户端或者服务端) 2.KDC(key  distribution center):是一个网络服务,提供ticket和临时会话密钥. ...

  2. 越狱Season 1-Episode 8: The Old Head

    Season 1, Episode 8: The Old Head -Michael: 17 days from now they strap my brother to an electric ch ...

  3. 计算机算法-C语言-统计字母数字个数解

    Question:输入一串以“?”结尾的字符,分别统计其中字母数字的个数,输出字母及数字的个数. Solve: #include<stdio.h> #include<stdlib.h ...

  4. 10个你能参与并学习的Java开源项目

    本文转载于:http://code.csdn.net/news/2822604 有很多备受关注的初创开源项目,下面列出十个项目是我觉得非常有趣的,涉及到的学习范围也很广.其中有些还在早期阶段,这对我们 ...

  5. E:nth-child(n)实现奇偶匹配

    <style> li:nth-child(2n){color:#f00;} /* 偶数 */ li:nth-child(2n+1){color:#000;} /* 奇数 */ </s ...

  6. C#→关于System.Data.Linq下的Table<TEntity> 泛型类 的问题

    Table<TEntity>表示表格记录,它是一个泛型集合类,它的元素就是表格实体对象.它提供一组方法,对元素进行添加删除操作,并可以通过DataContext将这些操作保存到数据库. 表 ...

  7. SVG添加链接(转载)

    转载地址:http://tech.techweb.com.cn/thread-258715-1-1.html 最基本的交互形式是链接.在 SVG 中,通过一个 <a> 标签提供链接,这与 ...

  8. Oracle数据库——半期测验

    一.使用system用户登录SQL*PLUS,使用命令将scott用户解锁,并将scott用户的密码修改为: t_你的学号后三位(例如:t_165).然后,以scott用户连接数据库. 1. 使用sy ...

  9. OpenJudge计算概论-配对碱基链

    /*===================================== 配对碱基链 总时间限制: 1000ms 内存限制: 65536kB 描述 脱氧核糖核酸(DNA)由两条互补的碱基链以双螺 ...

  10. Python命令行中输入pip提示不是内部或外部命令

    WIN764位,Python34 输入命令python -m pip