CF1829F.Forever Winter

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A snowflake graph is generated from two integers xx and yy, both greater than 11, as follows:

  • Start with one central vertex.
  • Connect xx new vertices to this central vertex.
  • Connect yy new vertices to each of these xx vertices.

For example, below is a snowflake graph for x=5x=5 and y=3y=3.

The snowflake graph above has a central vertex 1515, then x=5x=5 vertices attached to it (33, 66, 77, 88, and 2020), and then y=3y=3 vertices attached to each of those.

Given a snowflake graph, determine the values of xx and yy.

雪花图由两个均大于 1 的整数 xx 和 yy 生成,生成方式如下:

  • 从一个中心顶点开始;
  • 将 xx 个新顶点连接到该中心顶点;
  • 再将 yy 个新顶点分别连接到上述 xx 个顶点中的每一个。

例如,下图是 x=5x=5、y=3y=3 对应的雪花图。

上图所示的雪花图中,中心顶点为 1515,与之相连的 x=5x=5 个顶点为 33、66、77、88 和 2020,而每个这样的顶点又各自连接着 y=3y=3 个顶点。

给定一个雪花图,确定 xx 和 yy 的值。

输入格式

The first line contains a single integer tt (1≤t≤10001 \leq t \leq 1000) — the number of test cases.

The first line of each test case contains two integers nn and mm (2≤n≤2002 \leq n \leq 200; 1≤m≤min⁡(1000,n(n−1)2)1 \leq m \leq \min\left(1000, \frac{n(n-1)}{2}\right)) — the number of vertices and edges in the graph, respectively.

The next mm lines each contain two integers each uu and vv (1≤u,v≤n1 \leq u, v \leq n, u≠vu \neq v) — the numbers of vertices connected by an edge. The graph does not contain multiple edges and self-loops.

It is guaranteed that this graph is a snowflake graph for some integers xx and yy both greater than 11.

第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000)—— 测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 mm(2≤n≤2002 \leq n \leq 200;1≤m≤min⁡(1000,n(n−1)2)1 \leq m \leq \min\left(1000, \frac{n(n-1)}{2}\right))—— 分别表示图中顶点和边的数量。

接下来的 mm 行,每行包含两个整数 uu 和 vv(1≤u,v≤n1 \leq u, v \leq n,且 u≠vu \neq v)—— 表示由一条边连接的两个顶点的编号。该图不含重边和自环。

保证该图对某个大于 11 的整数 xx 和 yy 构成一个雪花图(snowflake graph)。

输出格式

For each test case, on a separate line output the values of xx and yy, in that order, separated by a space.

对于每个测试用例,在单独一行中按顺序输出 xx 和 yy 的值,二者之间用一个空格分隔。

输入输出样例

  • 输入#1

    3
    21 20
    21 20
    5 20
    13 20
    1 3
    11 3
    10 3
    4 8
    19 8
    14 8
    9 7
    12 7
    17 7
    18 6
    16 6
    2 6
    6 15
    7 15
    8 15
    20 15
    3 15
    7 6
    1 2
    1 3
    2 4
    2 5
    3 6
    3 7
    9 8
    9 3
    3 6
    6 2
    2 1
    5 2
    2 7
    4 3
    3 8

    输出#1

    5 3
    2 2
    2 3

说明/提示

The first test case is pictured in the statement. Note that the output 3 5 is incorrect, since xx should be output before yy.

第一个测试用例如题面图示所示。注意,输出 3 5 是错误的,因为 xx 应当在 yy 之前输出。

输入解题思路,AI测评打分。不知道怎么写?

首页