Codeforces Round 783 (Div. 1)
C
Half Queen Cover
Codeforces
2400
原题
← BD →
翻译中…

You are given a board with $n$ rows and $n$ columns, numbered from $1$ to $n$. The intersection of the $a$-th row and $b$-th column is denoted by $(a, b)$.

翻译中…

A half-queen attacks cells in the same row, same column, and on one diagonal. More formally, a half-queen on $(a, b)$ attacks the cell $(c, d)$ if $a=c$ or $b=d$ or $a-b=c-d$.

翻译中…

image The blue cells are under attack.

翻译中…

What is the minimum number of half-queens that can be placed on that board so as to ensure that each square is attacked by at least one half-queen?

翻译中…

Construct an optimal solution.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 10^5$) — the size of the board.

翻译中…

Output

翻译中…

In the first line print a single integer $k$ — the minimum number of half-queens.

翻译中…

In each of the next $k$ lines print two integers $a_i$, $b_i$ ($1 \le a_i, b_i \le n$) — the position of the $i$-th half-queen.

翻译中…

If there are multiple solutions, print any.

翻译中…

Note

翻译中…

Example $1$: one half-queen is enough. Note: a half-queen on $(1, 1)$ attacks $(1, 1)$.

翻译中…

Example $2$: one half-queen is enough too. $(1, 2)$ or $(2, 1)$ would be wrong solutions, because a half-queen on $(1, 2)$ does not attack the cell $(2, 1)$ and vice versa. $(2, 2)$ is also a valid solution.

翻译中…

Example $3$: it is impossible to cover the board with one half queen. There are multiple solutions for $2$ half-queens; you can print any of them.

翻译中…

样例

Input #1
1
Output #1
1
1 1
InputCopy OutputCopy
Input #2
2
Output #2
1
1 1
InputCopy OutputCopy
Input #3
3
Output #3
2
1 1
1 2
InputCopy OutputCopy
题目信息
题号
1667C
时间限制
1 s
内存限制
256 MB
标签
构造
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。