CF131E.Yet Another Task with Queens

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A queen is the strongest chess piece. In modern chess the queen can move any number of squares in any horizontal, vertical or diagonal direction (considering that there're no other pieces on its way). The queen combines the options given to the rook and the bishop.

There are mm queens on a square n×nn×n chessboard. You know each queen's positions, the ii -th queen is positioned in the square (ri,ci)(r_{i},c_{i}) , where rir_{i} is the board row number (numbered from the top to the bottom from 1 to nn ), and cic_{i} is the board's column number (numbered from the left to the right from 1 to nn ). No two queens share the same position.

For each queen one can count ww — the number of other queens that the given queen threatens (attacks). For a fixed attack direction only the first queen in this direction is under attack if there are many queens are on the ray of the attack. Obviously, for any queen ww is between 0 and 8, inclusive.

Print the sequence t0,t1,...,t8t_{0},t_{1},...,t_{8} , where tit_{i} is the number of queens that threaten exactly ii other queens, i.e. the number of queens that their ww equals ii .

输入格式

The first line of the input contains a pair of integers n,mn,m ( 1<=n,m<=1051<=n,m<=10^{5} ), where nn is the size of the board and mm is the number of queens on the board. Then mm following lines contain positions of the queens, one per line. Each line contains a pair of integers ri,cir_{i},c_{i} ( 1<=ri,ci<=n1<=r_{i},c_{i}<=n ) — the queen's position. No two queens stand on the same square.

输出格式

Print the required sequence t0,t1,...,t8t_{0},t_{1},...,t_{8} , separating the numbers with spaces.

输入输出样例

  • 输入#1

    8 4
    4 3
    4 8
    6 5
    1 6
    

    输出#1

    0 3 0 1 0 0 0 0 0 
  • 输入#2

    10 3
    1 1
    1 2
    1 3
    

    输出#2

    0 2 1 0 0 0 0 0 0 
首页