#P9923. [POI 2023/2024 R1] Przyciski

    ID: 11182 远端评测题 500ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>图论POI(波兰)2023Special Judge构造

[POI 2023/2024 R1] Przyciski

Background

Translated from XXXI Olimpiada Informatyczna - Stage I Przyciski

Problem Description

There is an n×nn \times n square grid with mm buttons inside.

You need to press some (at least one) buttons so that, for every row and every column, the parity of the number of pressed buttons is the same.

Input Format

The first line contains two positive integers n,mn, m.

The next mm lines each contain two positive integers, representing the coordinates of a button.

Output Format

If there is no solution, output one line NIE.

If there is a solution, output TAK on the first line. On the second line output a positive integer kk, the number of buttons you press. On the third line output several positive integers, the indices of the buttons you press.

3 6
1 1
1 2
2 2
3 1
3 2
3 3

TAK
4
1 2 4 5

9 1
1 1

NIE

见附件
TAK
4
1 2 10 11

见附件
TAK
4
1 2 100001 100002

Hint

Explanation for Sample 1: R1=2,R2=0,R3=2,C1=C2=2,C3=0R_1=2, R_2=0, R_3=2, C_1=C_2=2, C_3=0.

Constraints: For all testdata, 1n1000001 \le n \le 100000, 1mmin(n2,500000)1 \le m \le \min(n^2, 500000).

Subtask ID Additional Constraints Score
1 m20m \le 20 24
2 If there is a solution, it is guaranteed that an even-size solution exists.
3 If there is a solution, it is guaranteed that an odd-size solution exists.
4 28

If a solution exists and you correctly state that a solution exists but your construction is wrong, you can get 50%50\% of the score.

Translated by ChatGPT 5