题目链接:

B. Cells Not Under Attack

题意:

n*n的棋盘,现在放m个棋子,放一个棋子这一行和这一列就不会under attack了,每次放棋子回答有多少点还可能under attack;

思路:对行和列标记;

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=500+10;
const double eps=1e-6; int n,x[N],y[N]; int main()
{
int n,m;
read(n);read(m);
LL ans=(LL)n*n;
int fx=0,fy=0;
For(i,1,m)
{
int a,b;
read(a);read(b);
if(!x[a])
{
ans=ans-(n-fy);
x[a]=1;
fx++;
}
if(!y[b])
{
ans=ans-(n-fx);
y[b]=1;
fy++;
}
cout<<ans<<" ";
}
return 0;
}

  

codeforces 701B B. Cells Not Under Attack(水题)的更多相关文章

  1. codeforces 701 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 Gym 100187L L. Ministry of Truth 水题

    L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  3. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  4. Educational Codeforces Round 14 A. Fashion in Berland 水题

    A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...

  5. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  6. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  7. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告

    对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...

  8. Codeforces Round #194 (Div. 1) B. Chips 水题

    B. Chips Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/333/problem/B D ...

  9. Codeforces 777D:Cloud of Hashtags(水题)

    http://codeforces.com/problemset/problem/777/D 题意:给出n道字符串,删除最少的字符使得s[i] <= s[i+1]. 思路:感觉比C水好多啊,大概 ...

随机推荐

  1. tomcat知识点

    (1)使用线程池   Servlet引擎为每一个请求创建一个隔离的线程,分配这个线程给service()方法,在它执行完后移除这个线程.默认情况下,servlet引擎 为每一个请求创建新的线程.因为创 ...

  2. JavaScript中的Math方法演示

    <html> <head> <script type="text/javascript"> var num = 12.4; alert(Math ...

  3. [反汇编练习] 160个CrackMe之028

    [反汇编练习] 160个CrackMe之028. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...

  4. 设计模式——介绍与工厂模式(扁平管理模式VS职业经理人模式)

    本文主要对设计模式进行大概解说.特别是对工厂模式进行简明的解析: 一.设计模式的分类 创建型模式,共五种:工厂方法模式.抽象工厂模式.单例模式.建造者模式.原型模式. 结构型模式,共七种:适配器模式. ...

  5. npm 安装包无法继续下载? 卡住

    一般是由于package.json配置的项目名不对

  6. 第十六周 项目三-max带来的冲突

    分析以下程序出现的编译错误,给出解决的方案. #include<iostream> using namespace std; //定义函数模板 template<class T> ...

  7. python(1)- 初识python

    一.了解编程语言 1.编程语言的定义 编程语言即语言,语言的本质就是沟通,因而编程语言与英语 .法语.日语等所有语言并无区别,只不过英语是人与人之间沟通的介质,而编程语言则是程序员与计算机沟通的介质. ...

  8. codeforces 570 D. Tree Requests 树状数组+dfs搜索序

    链接:http://codeforces.com/problemset/problem/570/D D. Tree Requests time limit per test 2 seconds mem ...

  9. 生产制造追溯系统-IQC来料检验

    前言 相信大家都知道,任何一家工厂都有自己的仓库,用来存储采购回来的物料,那么在供应商将我们采购的物料送到工厂之后,我们都需要一个检验动作,也就是今天要说的===>IQC来料检验,这个检验动作是 ...

  10. linux 查找最后几条数据

    tail(选项)(参数) -n<N>或——line=<N>:输出文件的尾部N(N位数字)行内容. 例如:grep 查询 2018-02-*/*.log |tail -n 5查询 ...