Codeforces Round #364 (Div. 2), problem: (B) Cells Not Under Attack
来源:互联网 发布:挣钱的软件 编辑:程序博客网 时间:2024/05/01 14:49
题意:
给你一个地图。在其中安放炮塔。炮台可以打到与它同行同列的所有地方,求每一次安放一个炮台,剩余多少地方打不到
题解:
每一次认为是减少了矩形的长和宽,对于安放的地方已有同行的炮台,则只是矩形长减一,对于安放的地方已有同列的炮台,则只是矩形宽减一。
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <stack>using namespace std;typedef pair<int, int> p;typedef long long ll;typedef unsigned long long ull;#define pr(x) cout << #x << ": " << x << " "#define pl(x) cout << #x << ": " << x << endl;#define pri(a) printf("%d\n",(a))#define xx first#define yy second#define sa(n) scanf("%d", &(n))#define sal(n) scanf("%lld", &(n))#define sai(n) scanf("%I64d", &(n))#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++)int main(){ int n,num; cin>>n>>num; bool h[n+5]; bool l[n+5]; long long step = 1; long long nx=n; long long ny=n; long long ans[num+5]; memset(h,false,sizeof(h)); memset(l,false,sizeof(l)); int x;int y; while(cin>>x>>y){ if(l[y]==false){ l[y]=true; ny--; } if(h[x]==false){ h[x]=true; nx--; } long long a = nx*ny; ans[step] = a; step++; } for(int i=1;i<=num;i++){ cout<<ans[i]<<" "; } return 0;}
0 0
- Codeforces Round #364 (Div. 2) B. Cells Not Under Attack
- Codeforces Round #364 (Div. 2), problem: (B) Cells Not Under Attack
- Codeforces Round #364(Div. 2) A. Cards【模拟】 && B. Cells Not Under Attack【SET/规律】
- Codeforces Round #364 (Div. 2) B. Cells Not Under Attack 标记数组
- Codeforces Round #364 (Div. 2) B Cells Not Under Attack(数学)
- codeforces Round #364(Div.2)701B. Cells Not Under Attack ( math)
- 【Codeforces Round 364 (Div 2)B】【简单讨论】Cells Not Under Attack 行列炮台覆盖不被攻击格子数
- CF #364 (Div. 2) (B. Cells Not Under Attack 标记)
- 【数论】CF#364 div.2 B.Cells Not Under Attack
- Codeforces #364(Div.2)B.Cells Not Under Attack 【思维】
- codeforces--701B Cells Not Under Attack
- CodeForces 701B Cells Not Under Attack
- CodeForces 701B Cells Not Under Attack
- codeforces B. Cells Not Under Attack (数学)
- Codeforces#364(Div.2)B.Cell Not Under Attack
- B. Cells Not Under Attack
- B - Cells Not Under Attack
- Codeforces 701B Cells Not Under Attack(模拟)
- Latex文件分别用Texwork和Winedt打开时,产生中文乱码的解决方法
- Java中取得数组(array),集合(Collection)和字符串(String)的长度
- RecyclerView下拉刷新上拉加载
- App Webview远程调试学习小记
- gdb 调试
- Codeforces Round #364 (Div. 2), problem: (B) Cells Not Under Attack
- java 转义字符
- Codeforces Round #364 (Div. 2), problem: (D) As Fast As Possible
- mac Access denied for user 'root'@'localhost' (using password: YES)
- toggle 切换
- AOJ 0033 DFS
- Java中访问权限控制
- 内存映射原理
- Session入Redis