CF53E.Dead Ends

省选/NOI-

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are n junctions and m two way roads, at which one can get from each junction to any other one. The mayor wants to close some roads so that the number of roads left totaled to n - 1 roads and it were still possible to get from each junction to any other one. Besides, the mayor is concerned with the number of dead ends which are the junctions from which only one road goes. There shouldn't be too many or too few junctions. Having discussed the problem, the mayor and his assistants decided that after the roads are closed, the road map should contain exactly k dead ends. Your task is to count the number of different ways of closing the roads at which the following conditions are met:

  • There are exactly n - 1 roads left.
  • It is possible to get from each junction to any other one.
  • There are exactly k dead ends on the resulting map.

Two ways are considered different if there is a road that is closed in the first way, and is open in the second one.

伯顿市的生活变得艰难起来。该市道路过多,政府在道路维护上花费巨大。城市中共有 nn 个路口和 mm 条双向道路,且任意两个路口之间均可通过道路相互到达。市长希望关闭部分道路,使得最终剩余的道路总数恰好为 n−1n-1 条,同时仍能保证任意两个路口之间均可相互到达。此外,市长还关注“死胡同”(即仅连接一条道路的路口)的数量:既不能太多,也不能太少。经过讨论,市长及其助手决定:道路关闭后,路网中应恰好包含 kk 个死胡同。你的任务是计算满足以下条件的道路关闭方案数:

  • 恰好剩余 n−1n-1 条道路;
  • 任意两个路口之间均可相互到达;
  • 最终路网中恰好有 kk 个死胡同。

若两种方案中存在某条道路在第一种方案中被关闭、而在第二种方案中保持开放,则认为这两种方案不同。

输入格式

The first line contains three integers n, m and k (3 ≤ n ≤ 10, n - 1 ≤ m ≤ n·(n - 1) / 2, 2 ≤ k ≤ n - 1) which represent the number of junctions, roads and dead ends correspondingly. Then follow m lines each containing two different integers _v_1 and _v_2 (1 ≤ _v_1, _v_2 ≤ n, _v_1 ≠ _v_2) which represent the number of junctions connected by another road. There can be no more than one road between every pair of junctions. The junctions are numbered with integers from 1 to n. It is guaranteed that it is possible to get from each junction to any other one along the original roads.

第一行包含三个整数 nn、mm 和 kk(满足 3 ≤ n ≤ 103 \leq n \leq 10,n − 1 ≤ m ≤ n⋅(n − 1)/2n - 1 \leq m \leq n\cdot(n - 1)/2,2 ≤ k ≤ n − 12 \leq k \leq n - 1),分别表示路口数量、道路数量和死胡同数量。接下来的 mm 行,每行包含两个不同的整数 v1v_1 和 v2v_2(满足 1 ≤ v1, v2 ≤ n1 \leq v_1, v_2 \leq n,且 v1 ≠ v2v_1 \neq v_2),表示由一条道路连接的两个路口编号。任意一对路口之间至多只有一条道路。路口编号为从 11 到 nn 的整数。保证在原始道路网络中,任意两个路口之间均可达。

输出格式

Print a single number — the required number of ways.

输出一个数字——所需的方案数。

输入输出样例

  • 输入#1

    3 3 2
    1 2
    2 3
    1 3

    输出#1

    3
  • 输入#2

    4 6 2
    1 2
    2 3
    3 4
    4 1
    1 3
    2 4

    输出#2

    12
  • 输入#3

    4 6 3
    1 2
    2 3
    3 4
    4 1
    1 3
    2 4

    输出#3

    4

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

首页