CF402C.Searching for Graph
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
- the graph contains exactly 2_n_ + p edges;
- the graph doesn't contain self-loops and multiple edges;
- for any integer k (1 ≤ k ≤ n), any subgraph consisting of k vertices contains at most 2_k_ + p edges.
A subgraph of a graph is some set of the graph vertices and some set of the graph edges. At that, the set of edges must meet the condition: both ends of each edge from the set must belong to the chosen set of vertices.
Your task is to find a p-interesting graph consisting of n vertices.
我们称一个包含 n 个顶点的无向图为 p-有趣图,当且仅当满足以下条件:
- 该图恰好包含 2n+p 条边;
- 该图不含自环和重边;
- 对任意整数 k(其中 1≤k≤n),由任意 k 个顶点构成的任意子图至多包含 2k+p 条边。
图的一个子图是指图中某些顶点的集合以及某些边的集合;其中边的集合需满足:每条边的两个端点都必须属于所选的顶点集合。
你的任务是构造一个由 n 个顶点组成的 p-有趣图。
输入格式
The first line contains a single integer t (1 ≤ t ≤ 5) — the number of tests in the input. Next t lines each contains two space-separated integers: n, p (5 ≤ n ≤ 24; p ≥ 0;
) — the number of vertices in the graph and the interest value for the appropriate test.
It is guaranteed that the required graph exists.
第一行包含一个整数 t(1≤t≤5)—— 输入中测试用例的数量。接下来的 t 行,每行包含两个以空格分隔的整数:n、p(5≤n≤24;p≥0;
)—— 分别表示图中顶点的数量以及对应测试用例的兴趣值。
保证所要求的图一定存在。
输出格式
For each of the t tests print 2_n_ + p lines containing the description of the edges of a p-interesting graph: the i-th line must contain two space-separated integers a__i, b__i (1 ≤ a__i, b__i ≤ n; a__i ≠ b__i) — two vertices, connected by an edge in the resulting graph. Consider the graph vertices numbered with integers from 1 to n.
Print the answers to the tests in the order the tests occur in the input. If there are multiple solutions, you can print any of them.
对于每个测试用例,输出 2n+p 行,每行描述一个 p-interesting 图中的一条边:第 i 行必须包含两个以空格分隔的整数 ai, bi(满足 1≤ai, bi≤n;且 ai=bi),表示图中连接顶点 ai 与 bi 的一条边。图的顶点编号为 1 到 n 的整数。
请按照输入中测试用例出现的顺序输出对应答案。若存在多种可行解,输出任意一种即可。
输入输出样例
输入#1
1 6 0
输出#1
1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6
输入解题思路,AI测评打分。不知道怎么写?