noi.ac day6t1 queen
分析
我就是个BT......
直接排序后开数组记录每条线上的信息,注意由于每个点只会影响前面第一个点和后面第一个点,所以记录每条线的前一个点就行了。
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
struct node {
int x,y;
};
node d[];
int px[],py[],pa[],pb[],tot[],ans[];
inline bool cmp(const node a,const node b){
return a.x==b.x?a.y<b.y:a.x<b.x;
}
int main(){
int n,m,i,j,k;
scanf("%d%d",&n,&m);
for(i=;i<=m;i++)scanf("%d%d",&d[i].x,&d[i].y);
sort(d+,d+m+,cmp);
for(i=;i<=m;i++){
int x=d[i].x,y=d[i].y;
if(px[x])tot[i]++,tot[px[x]]++;
if(py[y])tot[i]++,tot[py[y]]++;
if(pa[x+y])tot[i]++,tot[pa[x+y]]++;
if(pb[x-y+n])tot[i]++,tot[pb[x-y+n]]++;
px[x]=i,py[y]=i,pa[x+y]=i,pb[x-y+n]=i;
}
for(i=;i<=m;i++)ans[tot[i]]++;
for(i=;i<;i++)printf("%d ",ans[i]);
return ;
}
noi.ac day6t1 queen的更多相关文章
- NOI.AC NOIP模拟赛 第六场 游记
NOI.AC NOIP模拟赛 第六场 游记 queen 题目大意: 在一个\(n\times n(n\le10^5)\)的棋盘上,放有\(m(m\le10^5)\)个皇后,其中每一个皇后都可以向上.下 ...
- # NOI.AC省选赛 第五场T1 子集,与&最大值
NOI.AC省选赛 第五场T1 A. Mas的童年 题目链接 http://noi.ac/problem/309 思路 0x00 \(n^2\)的暴力挺简单的. ans=max(ans,xor[j-1 ...
- NOI.ac #31 MST DP、哈希
题目传送门:http://noi.ac/problem/31 一道思路好题考虑模拟$Kruskal$的加边方式,然后能够发现非最小生成树边只能在一个已经由边权更小的边连成的连通块中,而树边一定会让两个 ...
- NOI.AC NOIP模拟赛 第五场 游记
NOI.AC NOIP模拟赛 第五场 游记 count 题目大意: 长度为\(n+1(n\le10^5)\)的序列\(A\),其中的每个数都是不大于\(n\)的正整数,且\(n\)以内每个正整数至少出 ...
- NOI.AC NOIP模拟赛 第二场 补记
NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...
- NOI.AC NOIP模拟赛 第一场 补记
NOI.AC NOIP模拟赛 第一场 补记 candy 题目大意: 有两个超市,每个超市有\(n(n\le10^5)\)个糖,每个糖\(W\)元.每颗糖有一个愉悦度,其中,第一家商店中的第\(i\)颗 ...
- NOI.AC NOIP模拟赛 第四场 补记
NOI.AC NOIP模拟赛 第四场 补记 子图 题目大意: 一张\(n(n\le5\times10^5)\)个点,\(m(m\le5\times10^5)\)条边的无向图.删去第\(i\)条边需要\ ...
- NOI.AC NOIP模拟赛 第三场 补记
NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...
- NOI.AC WC模拟赛
4C(容斥) http://noi.ac/contest/56/problem/25 同时交换一行或一列对答案显然没有影响,于是将行列均从大到小排序,每次处理限制相同的一段行列(呈一个L形). 问题变 ...
随机推荐
- Collection集合存储自定义对象练习
public class Student { private String name; private int age; public Student() { super(); } public St ...
- c语言%.*s是什么
int i; ;i<;i++) printf("%.*s%s\n", i, " ", "########"); ; *用来指定宽度,对 ...
- hashmap&linkedlist
import java.util.HashMap; import java.util.Iterator; public class hashmap1 { public static void main ...
- ADMEMS软件架构的4个阶段
业界软件架构设计的方法论很多,各有各自的应用场景和特点,下文结合ADMEMS(Architecture Design Method has been Extended to Method System ...
- BZOJ3809:Gty的二逼妹子序列
浅谈莫队:https://www.cnblogs.com/AKMer/p/10374756.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php?i ...
- bzoj 2744 [HEOI2012]朋友圈——补图!+匈牙利算法
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2744 求最大的团<==>补图(有边的变成没边.没边的变成有边)的最大独立集! A ...
- flask之全局对象
from flask import current_app, g g is a special object that is unique for each request. It is used t ...
- Azure VNet介绍
Azure VNet的介绍 VNet是Azure云中逻辑隔离的虚拟网络.它包含两个含义: Azure的用户可以在VNet中创建自己的各种资源,感觉想自己的数据中心中一样; 在一个VNet中创建的资源和 ...
- clone对象的克隆
用一句简单的话来说就是浅拷贝,只是对指针的拷贝,拷贝后两个指针指向同一个内存空间,深拷贝不但对指针进行拷贝,而且对指针指向的内容进行拷贝,经深拷贝后的指针是指向两个不同地址的指针. 等多 http:/ ...
- UE4异步载入资源
转自:http://blog.ch-wind.com/ue4%E5%BC%82%E6%AD%A5%E8%BD%BD%E5%85%A5%E8%B5%84%E6%BA%90/ 所有的“硬”指针指向的资源都 ...