#P16344. [科大国创杯初中组 2026] 构造题

    ID: 18426 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>安徽Special JudgeFibonacci 数列构造2026科创活动初中活动科大国创杯

[科大国创杯初中组 2026] 构造题

Background

Subtask 0 uses community testdata, and Subtask 1 uses official testdata.

Problem Description

You need to construct a directed acyclic graph (DAG) with nn vertices and mm edges without multiple edges (vertices are numbered starting from 11). The in-degree of vertex 11 and the out-degree of vertex nn must both be 00. Also, for every integer ii in 0∼p0 \sim p, it must be possible to keep only some directed edges in the graph so that the number of distinct paths from vertex 11 to vertex nn is exactly ii. Please output the DAG you constructed, and for each ii, specify which edges need to be kept.

The answer is not unique, so you only need to output any feasible solution. See the output format for details. You may choose the values of nn and mm yourself, but you must ensure n≤24,m≤65n \le 24, m \le 65.

A path PP from vertex 11 to vertex nn that passes through ∣P∣|P| vertices can be described as a sequence of length ∣P∣|P|, (P1,P2,…,P∣P∣)(P_1, P_2, \dots, P_{|P|}), where P1=1,P∣P∣=nP_1 = 1, P_{|P|} = n, and for i=1,2,…,∣P∣−1i = 1, 2, \dots, |P| - 1, the graph contains a directed edge Pi→Pi+1P_i \to P_{i+1}.

Two paths A,BA, B are different if and only if ∣A∣≠∣B∣|A| \ne |B|, or there exists a positive integer ii in 1∼∣A∣1 \sim |A| such that Ai≠BiA_i \ne B_i.

Input Format

The input contains only one line with a positive integer pp.

Output Format

  • On the first line, output two positive integers n,mn, m, representing the number of vertices and edges in the DAG you construct.
  • On the next mm lines, on the ii-th line output two positive integers u,vu, v, representing the ii-th directed edge u→vu \to v in the graph.
  • On the next p+1p+1 lines, on the ii-th line output a string of length mm consisting only of 0 and 1, indicating which edges to keep in order to make the number of distinct paths from vertex 11 to vertex nn equal to i−1i-1. From left to right, the jj-th character is 1 if the jj-th edge is kept, and 0 otherwise.
3
5 6
1 2
2 5
1 3
3 5
1 4
4 5
000000
110000
111100
111111

Hint

Sample Explanation

In the sample, p=3p = 3. The figure on the next page shows a feasible graph constructed by the sample output.

When none of the six edges are selected, vertex 11 obviously cannot reach vertex 55, so the number of paths is 00.

When only edges 11 and 22 are kept, there is only one path from vertex 11 to vertex 55 (1→2→51 \to 2 \to 5), so the number of paths is 11.

When edges 1,2,3,41, 2, 3, 4 are kept, there are two paths from vertex 11 to vertex 55 (1→2→51 \to 2 \to 5 and 1→3→51 \to 3 \to 5), so the number of paths is 22.

When all edges are kept, there are three paths from vertex 11 to vertex 55 (1→2→5,1→3→51 \to 2 \to 5, 1 \to 3 \to 5 and 1→4→51 \to 4 \to 5), so the number of paths is 33.

Therefore, this construction is valid.

Constraints

For all testdata, it is guaranteed that p≤75000p \le 75000.

This problem has a total of twenty test points. For each test point, the input is known (see the table below). You will get the score for a test point only if your construction is valid and satisfies n≤24,m≤65n \le 24, m \le 65. Otherwise, you will get no score for that test point.

Test Point ID p=p = Test Point ID p=p = Test Point ID p=p = Test Point ID p=p =
11 55 66 300300 1111 60006000 1616 3500035000
22 1010 77 600600 1212 80008000 1717 4500045000
33 2020 88 10001000 1313 1000010000 1818 5500055000
44 5050 99 20002000 1414 1500015000 1919 6500065000
55 100100 1010 40004000 1515 2500025000 2020 7500075000

Friendly Reminder

  • When pp is large, the output size is large, so please use a proper way to output. You should also open the output file properly to prevent your computer from crashing.

  • A checker checker.cpp is provided for you to test whether your construction is valid. The provided checker is different from the one used in the final judging, and you do not need to care about its internal details. Please extract the file provided with this problem.

  • Extract checker.cpp to the folder where your program for this problem is located. Then right-click in that folder, choose “Open in Terminal”, and compile checker.cpp using the following command: g++ checker.cpp -o checker -O2 -std=c++14

  • Then test your output using the following command: ./checker construct.in construct.out

  • After the command runs successfully, if your construction is valid, you will see Accepted. Otherwise, you will see Wrong answer and detailed error information.

Translated by ChatGPT 5