zoukankan      html  css  js  c++  java
  • 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[100100];
    int px[200100],py[200100],pa[200100],pb[200100],tot[100100],ans[10];
    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=1;i<=m;i++)scanf("%d%d",&d[i].x,&d[i].y);
        sort(d+1,d+m+1,cmp);
        for(i=1;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=1;i<=m;i++)ans[tot[i]]++;
        for(i=0;i<9;i++)printf("%d ",ans[i]);
        return 0;
    }
  • 相关阅读:
    php json_encode怪问题
    给phpcms v9添加热门搜索关键词
    magento 1.6 后台无法登录解决办法
    08 baidu QA
    java exception
    java thread / process / thread runnable / thread sleep / thread run
    java reflect
    db sysbase
    内存单元
    分段的方式来管理内存
  • 原文地址:https://www.cnblogs.com/yzxverygood/p/9797888.html
Copyright © 2011-2022 走看看