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. Codeforces Round #372 (Div. 2)

    Codeforces Round #372 (Div. 2) C. Plus and Square Root 题意 一个游戏中,有一个数字\(x\),当前游戏等级为\(k\),有两种操作: '+'按钮 ...

  2. android中常见对话框之一AlertDialog

    在Android应用中,有多种对话框:Dialog.AlertDialog.ProgressDialog.时间.日期等对话框. (1)Dialog类,是一切对话框的基类,需要注意的是,Dialog类虽 ...

  3. P188 实战练习(父类和子类)

    1.创建一个父类,在父类中创建两个方法,在子类中覆盖第二个方法,为子类创建一个对象,将它向上转型到基类并调用这个方法. 创建Computer父类: package org.hanqi.practise ...

  4. JavaScript验证

    <script type="text/javascript">    /*密码*/    function password()    {        var pas ...

  5. awesome-nlp

    awesome-nlp  A curated list of resources dedicated to Natural Language Processing Maintainers - Keon ...

  6. 我今天也学习了做jquery插件

    先贴代码 (function ( $ ) { var id=33; $.fn.validate=function(options){ // This is the easiest way to hav ...

  7. 可视化SNV安装

    以前也安装过非图形化的SVN SERVER,但大多都需要比较复杂的配置,而且操作不太友好,所以其拥有可视化功能就比较重要了. 好了,开始干活吧. 说明:测试机为开发爬虫用的服务器,配置不高 准备工作: ...

  8. webqq协议请求交互过程

    1.http://my.oschina.net/ij2ee/blog/191692 2.http://www.qqxieyi.com/fenxi_show.asp?id=34

  9. 解决json包含html标签无法显示的问题

    要是在json中包含html标签的话,在js接收数据的时候就会出现问题,导致接收失败. 所以在java端,对json包含有html标签的句子先进行转义. package com.alibaba.int ...

  10. hadoop(四):配置参数

    hadoop参数配置,主要是配置 core-site.xml,hdfs-site.xml,mapred-site.xml 三个配置文件,core-site.xml是全局配置,hdfs-site.xml ...