P17140 [NOI 2026] Segments

Background

The statement and sample attachments are from [QOJ](https://qoj.ac/contest/3938/problem/18983)。 When submitting to Luogu, you do not need to include the header `#include "segment.h"`。Just copy ```cpp void init(int c, int t); std::vector segment(int n, int m, int k, std::vector l, std::vector r); ``` to the beginning of your program, and compile with a C++17 or higher compiler.

Description

Xiao $L$ has $n$ segments contained in $[1,m]$。The $i$-th ($0\le i

Input Format

You can compile in this problem directory using the following command to obtain an executable file: ```bash g++ grader.cpp segment.cpp -o segment -O2 -std=c++14 -static ``` For the compiled executable `segment`: - The executable will read input from standard input in the following format: - The first line contains two non-negative integers $c,t$. - Then follow the testdata groups. For each group of testdata: - The first line contains three positive integers $n,m,k$. - Line $i+2$ ($0\le i

Output Format

N/A

Explanation/Hint

### 【Sample $1$ Explanation】 For the first group of testdata: - For size $1$, the sets $\{0\},\{1\},\{2\}$ are all elegant. - For size $2$, the sets $\{0,1\},\{1,2\},\{0,2\}$ are all elegant. - For size $3$, the set $\{0,1,2\}$ constructs a 3-cycle, so it is not elegant. Therefore the answers are $3,3,0$. For the second group of testdata: - For size $1$, all $4$ sets are elegant. - For size $2$, $\{0,1\},\{1,2\},\{2,3\}$ are elegant. - For size $3$, $\{0,1,2\},\{1,2,3\}$ are elegant. - The size $4$ set $\{0,1,2,3\}$ is elegant. Therefore the answers are $4,3,2,1$. ### 【Sample $2$】 See `segment/segment2.in` and `segment/segment2.ans` in the contestant directory. This sample satisfies the constraints of test points $6\sim8$. ### 【Sample $3$】 See `segment/segment3.in` and `segment/segment3.ans` in the contestant directory. This sample satisfies the constraints of test points $9,10$. ### 【Sample $4$】 See `segment/segment4.in` and `segment/segment4.ans` in the contestant directory. This sample satisfies the constraints of test points $11\sim15$. ### 【Sample $5$】 See `segment/segment5.in` and `segment/segment5.ans` in the contestant directory. This sample satisfies the constraints of test points $16\sim18$. ### 【Sample $6$】 See `segment/segment6.in` and `segment/segment6.ans` in the contestant directory. This sample satisfies the constraints of test points $22,23$. ### 【Sample $7$】 See `segment/segment7.in` and `segment/segment7.ans` in the contestant directory. This sample satisfies the constraints of test points $24,25$. Translated by ChatGPT 5