#P6020. [Ynoi2010] Exponential tree

[Ynoi2010] Exponential tree

Problem Description

Given n,kn, k, you need to construct a matrix Ai,jA_{i,j} that only contains 00 and 11, where 0i,jn0\le i,j\le n, satisfying:

  1. Ai,i=1A_{i,i}=1.
  2. Ai,i+1=1A_{i,i+1}=1.
  3. For i>ji>j, Ai,j=0A_{i,j}=0.
  4. If Ai,j=1A_{i,j}=1 and ji>1j-i>1, then there exists i<t<ji<t<j such that Ai,t=At,j=1A_{i,t}=A_{t,j}=1.
  5. For iji\le j, (Ak)i,j>0(A^k)_{i,j}>0.

You need to output every (i,j)(i,j) such that Ai,j=1A_{i,j}=1 and ji>1j-i>1. Let there be mm such pairs (i,j)(i,j).

If your output does not meet the requirements, you cannot get any score for that test point. If your output meets the requirements, then it will be scored based on mm.

Input Format

One line with two integers n,kn, k.

Output Format

The first line contains an integer mm. The next mm lines each contain two integers i,ji, j, representing each pair (i,j)(i,j) that satisfies Ai,j=1A_{i,j}=1 and ji>1j-i>1, in order.

3 2
1
0 2

Hint

For 100%100\% of the testdata, 1900n20001900\le n\le 2000 and 2k152\le k\le 15.

kk f(n,k)f(n,k)
2 7.987
3 3.8085
4 2.396
5 1.961
6 1.6065
7 1.451
8 1.2535
9 1.1975
10 1.099
11 1.07
12 1.034
13 1.0115
14 1.001
15 0.994

Each 2k152\le k\le 15 corresponds to a subtask with total score s(k)s(k). The score of each subtask is the minimum score among all test points in that subtask.

For each test point, the score equals the subtask's total score multiplied by $\max\left(0,1-\sqrt{\max\left(0,\frac{m}{n\cdot f(k)}-1\right)}\right)$.

Translated by ChatGPT 5