题目链接:

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. visual studio usage tips

    reset all settings on visual stdio microsoft visual studio X\common7\ide\devenv.exe /setup /resetuse ...

  2. win10任务管理器开机老是自己打开

    win10任务管理器开机老是自己打开 学习了:https://zhidao.baidu.com/question/332868722086816045.html 还没有注意过这个东西:系统失败-> ...

  3. navicat小经验和快捷键

    1.有时按快捷键Ctrl+F搜某条数据的时候搜不到,但是能用sql查出来,这是怎么回事? Ctrl+F只能搜本页数据,不在本页的数据搜不到,navicat每页只显示1000条数据.在数据多的时候nav ...

  4. Flash中如何使用滤镜

    使用滤镜 应用或删除滤镜 复制和粘贴滤镜 为对象应用预设滤镜 启用或禁用应用于对象的滤镜 启用或禁用应用于对象的所有滤镜 创建预设滤镜库 对象每添加一个新的滤镜,在属性检查器中,就会将其添加到该对象所 ...

  5. log4j:WARN Please initialize the log4j system properly解决的方法

    要解决问题很easy,建立LOG4J 的配置文件就可以. 在src 文件夹下创建配置文件,选 一.择菜单File > New > File,文件名称输入log4j.properties,文 ...

  6. POJ2386 Lake Counting 【DFS】

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20782   Accepted: 10473 D ...

  7. MRP routing设置释疑

    Jeffer9@gmail.com         工艺是指在不同工作中心执行的作业序列         作业的详细信息 Number of cycles 在该工作中心操作几个循环 Number of ...

  8. centos 使用 CP 命令 不提示 覆盖

    今天 在我的VPS上拷一个目录,但放的地方有一个同名目录并且里面还有文件.如是直接拷过去,结果有N个要确认替换的提示,直接CTRL+C,在网上搜了把,发现有几个方法能够解决,方法例如以下: 一般我们使 ...

  9. python(38)- 网络编程socket

    一 客户端/服务器架构 即C/S架构,包括 1.硬件C/S架构(打印机) 2.软件C/S架构(web服务) 美好的愿望: 最常用的软件服务器是 Web 服务器.一台机器里放一些网页或 Web 应用程序 ...

  10. VueJS表达式支持:逻辑控制或运算

    HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <titl ...