A8309 | Yet Another Task with Queens
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $m$ queens on a square $n×n$ chessboard. You know each queen's positions, the $i$ -th queen is positioned in the square $(r_{i},c_{i})$ , where $r_{i}$ is the board row number (numbered from the top to the bottom from 1 to $n$ ), and $c_{i}$ is the board's column number (numbered from the left to the right from 1 to $n$ ). No two queens share the same position.
For each queen one can count $w$ — 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 $w$ is between 0 and 8, inclusive.
Print the sequence $t_{0},t_{1},...,t_{8}$ , where $t_{i}$ is the number of queens that threaten exactly $i$ other queens, i.e. the number of queens that their $w$ equals $i$ .
There are $m$ queens on a square $n×n$ chessboard. You know each queen's positions, the $i$ -th queen is positioned in the square $(r_{i},c_{i})$ , where $r_{i}$ is the board row number (numbered from the top to the bottom from 1 to $n$ ), and $c_{i}$ is the board's column number (numbered from the left to the right from 1 to $n$ ). No two queens share the same position.
For each queen one can count $w$ — 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 $w$ is between 0 and 8, inclusive.
Print the sequence $t_{0},t_{1},...,t_{8}$ , where $t_{i}$ is the number of queens that threaten exactly $i$ other queens, i.e. the number of queens that their $w$ equals $i$ .
输入格式
The first line of the input contains a pair of integers $n,m$ ( $1<=n,m<=10^{5}$ ), where $n$ is the size of the board and $m$ is the number of queens on the board. Then $m$ following lines contain positions of the queens, one per line. Each line contains a pair of integers $r_{i},c_{i}$ ( $1<=r_{i},c_{i}<=n$ ) — the queen's position. No two queens stand on the same square.
输出格式
Print the required sequence $t_{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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted