传送门

分析

我就是个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的更多相关文章

  1. NOI.AC NOIP模拟赛 第六场 游记

    NOI.AC NOIP模拟赛 第六场 游记 queen 题目大意: 在一个\(n\times n(n\le10^5)\)的棋盘上,放有\(m(m\le10^5)\)个皇后,其中每一个皇后都可以向上.下 ...

  2. # NOI.AC省选赛 第五场T1 子集,与&最大值

    NOI.AC省选赛 第五场T1 A. Mas的童年 题目链接 http://noi.ac/problem/309 思路 0x00 \(n^2\)的暴力挺简单的. ans=max(ans,xor[j-1 ...

  3. NOI.ac #31 MST DP、哈希

    题目传送门:http://noi.ac/problem/31 一道思路好题考虑模拟$Kruskal$的加边方式,然后能够发现非最小生成树边只能在一个已经由边权更小的边连成的连通块中,而树边一定会让两个 ...

  4. NOI.AC NOIP模拟赛 第五场 游记

    NOI.AC NOIP模拟赛 第五场 游记 count 题目大意: 长度为\(n+1(n\le10^5)\)的序列\(A\),其中的每个数都是不大于\(n\)的正整数,且\(n\)以内每个正整数至少出 ...

  5. NOI.AC NOIP模拟赛 第二场 补记

    NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...

  6. NOI.AC NOIP模拟赛 第一场 补记

    NOI.AC NOIP模拟赛 第一场 补记 candy 题目大意: 有两个超市,每个超市有\(n(n\le10^5)\)个糖,每个糖\(W\)元.每颗糖有一个愉悦度,其中,第一家商店中的第\(i\)颗 ...

  7. NOI.AC NOIP模拟赛 第四场 补记

    NOI.AC NOIP模拟赛 第四场 补记 子图 题目大意: 一张\(n(n\le5\times10^5)\)个点,\(m(m\le5\times10^5)\)条边的无向图.删去第\(i\)条边需要\ ...

  8. NOI.AC NOIP模拟赛 第三场 补记

    NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...

  9. NOI.AC WC模拟赛

    4C(容斥) http://noi.ac/contest/56/problem/25 同时交换一行或一列对答案显然没有影响,于是将行列均从大到小排序,每次处理限制相同的一段行列(呈一个L形). 问题变 ...

随机推荐

  1. Nhibernate系列学习之(四) 数据操作

    数据操作,在这里主要介绍INSERT.UPDATE.DELETE.我们在使用NHibernate的时候,如果只是查询数据,不需要改变数据库的值,那么是不需要提交或者回滚到数据库的. 一.INSERT ...

  2. L119

    A big collaboration is trying to understand diseases of the psycheDiseases of the psyche have always ...

  3. fiddler抓包

    1.fiddler安装 下载exe安装文件,傻瓜式安装 2.fiddler配置 点击Tools -->Telerik Fiddler Options -->Https,进入以下对话框 Ht ...

  4. python 类的定义和继承

    python 2 中类 一.类定义: ? 1 2 class <类名>:   <语句> 类实例化后,可以使用其属性,实际上,创建一个类之后,可以通过类名访问其属性如果直接使用类 ...

  5. Android Studio 学习 - Activity生命周期

    落下两晚了,继续学习…… 先粘贴2张官方给的流程图: ------------------------------------------------------------------------- ...

  6. Spring通过注解方式实现定时任务

    XML配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http:/ ...

  7. Linux下anaconda的安装

    http://peteryuan.net/use-anaconda/ http://www.jianshu.com/p/03d757283339

  8. 2017/2/22怎么判断mongodb服务已经启动了?

    打开任务管理器,看看服务下面是否有个MongoDB,有就表示成功

  9. Maven里头的pom.xml配置详解

    正常的pom配置文件如下所示: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http ...

  10. laravel 接收json串

    在做项目的时候发现 用平时的$request->all() 无法获取到请求值 然后这样解决了 但是还是不知道原因 学习源头: http://www.cnblogs.com/anjuncc/p/5 ...