#P10871. [COTS 2022] 皇后 Kraljice

    ID: 12342 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2022Special JudgeO2优化构造COCI(克罗地亚)

[COTS 2022] 皇后 Kraljice

Background

Translated from Izborne Pripreme 2022 (Croatian IOI/CEOI Team Selection) D1T1。1s,0.5G\texttt{1s,0.5G}

Problem Description

There is an N×NN \times N chessboard. Place queens on empty squares one by one, maximizing the number of queens placed. You need to construct a valid plan.

A queen can be placed on a square if and only if that square is attacked by an even number of queens.

A queen attacks a square if and only if the queen's square and the attacked square are in the same row, column, or diagonal.

Input Format

One line with an integer NN

Output Format

The first line contains an integer KK, the maximum number of queens that can be placed.

The next KK lines each contain two integers x,yx, y, describing the position where a queen is placed.

1
1
1 1


2
1
1 1

3
9
2 3
3 1
2 2
1 1
3 3
3 2
1 2
1 3
2 1

Hint

Sample Explanation

Explanation for sample 33

Constraints

For 100%100\% of the data, it is guaranteed that 1N2101 \le N \le 2^{10}

Subtask ID Points Constraints
11 66 1N241 \le N \le 2^4
22 1111 1N261 \le N \le 2^6
33 2828 1N281 \le N \le 2^8
44 5555 No additional constraints

Translated by ChatGPT 5