CF1662C.European Trip

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The map of Europe can be represented by a set of nn cities, numbered from 11 through nn, which are connected by mm bidirectional roads, each of which connects two distinct cities. A trip of length kk is a sequence of k+1k+1 cities v1,v2,…,vk+1v_1, v_2, \ldots, v_{k+1} such that there is a road connecting each consecutive pair viv_i, vi+1v_{i+1} of cities, for all 1≤i≤k1 \le i \le k. A special trip is a trip that does not use the same road twice in a row, i.e., a sequence of k+1k+1 cities v1,v2,…,vk+1v_1, v_2, \ldots, v_{k+1} such that it forms a trip and vi≠vi+2v_i \neq v_{i + 2}, for all 1≤i≤k−11 \le i \le k - 1.

Given an integer kk, compute the number of distinct special trips of length kk which begin and end in the same city. Since the answer might be large, give the answer modulo 998 244 353998\,244\,353.

欧洲地图可以表示为由 nn 个城市(编号从 11 到 nn)组成的集合,这些城市之间由 mm 条双向道路连接,每条道路连接两个不同的城市。长度为 kk 的行程是指一个包含 k+1k+1 个城市的序列 v1,v2,…,vk+1v_1, v_2, \ldots, v_{k+1},使得对每个 1≤i≤k1 \le i \le k,城市 viv_i 与 vi+1v_{i+1} 之间均存在一条道路。特殊行程是指不连续两次经过同一条道路的行程,即一个包含 k+1k+1 个城市的序列 v1,v2,…,vk+1v_1, v_2, \ldots, v_{k+1},它本身是一个行程,且对所有 1≤i≤k−11 \le i \le k - 1 满足 vi≠vi+2v_i \neq v_{i + 2}。

给定整数 kk,计算所有起点与终点为同一城市的、长度为 kk 的不同特殊行程的数量。由于答案可能很大,请将结果对 998 244 353998\,244\,353 取模后输出。

输入格式

The first line contains three integers nn, mm and kk (3≤n≤1003 \le n \le 100, 1≤m≤n(n−1)/21 \le m \le n(n - 1) / 2, 1≤k≤1041 \le k \le 10^4) — the number of cities, the number of roads and the length of trips to consider.

Each of the following mm lines contains a pair of distinct integers aa and bb (1≤a,b≤n1 \le a, b \le n) — each pair represents a road connecting cities aa and bb. It is guaranteed that the roads are distinct (i.e., each pair of cities is connected by at most one road).

第一行包含三个整数 nn、mm 和 kk(3≤n≤1003 \le n \le 100,1≤m≤n(n−1)/21 \le m \le n(n - 1) / 2,1≤k≤1041 \le k \le 10^4),分别表示城市的数量、道路的数量以及需要考虑的旅行长度。

接下来的 mm 行中,每行包含一对互异的整数 aa 和 bb(1≤a,b≤n1 \le a, b \le n),每对数表示一条连接城市 aa 和 bb 的道路。保证所有道路互不相同(即任意两个城市之间至多只有一条道路相连)。

输出格式

Print the number of special trips of length kk which begin and end in the same city, modulo 998 244 353998\,244\,353.

输出长度为 kk 且起点与终点为同一城市的特殊行程的数量,结果对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    4 5 2
    4 1
    2 3
    3 1
    4 3
    2 4

    输出#1

    0
  • 输入#2

    4 5 3
    1 3
    4 2
    4 1
    2 1
    3 4

    输出#2

    12
  • 输入#3

    8 20 12
    4 3
    6 7
    5 7
    8 2
    8 3
    3 1
    4 7
    8 5
    5 4
    3 5
    7 1
    5 1
    7 8
    3 2
    4 2
    5 2
    1 4
    4 8
    3 6
    4 6

    输出#3

    35551130

说明/提示

In the first sample, we are looking for special trips of length 22, but since we cannot use the same road twice once we step away from a city we cannot go back, so the answer is 00.

In the second sample, we have the following 1212 special trips of length 33 which begin and end in the same city: (1,2,4,1)(1, 2, 4, 1), (1,3,4,1)(1, 3, 4, 1), (1,4,2,1)(1, 4, 2, 1), (1,4,3,1)(1, 4, 3, 1), (2,1,4,2)(2, 1, 4, 2), (2,4,1,2)(2, 4, 1, 2), (3,1,4,3)(3, 1, 4, 3), (3,4,1,3)(3, 4, 1, 3), (4,1,3,4)(4, 1, 3, 4), (4,3,1,4)(4, 3, 1, 4), (4,1,2,4)(4, 1, 2, 4), and (4,2,1,4)(4, 2, 1, 4).

在第一个样例中,我们需要寻找长度为 22 的特殊路径,但由于不能重复使用同一条道路,因此一旦离开某个城市就无法返回,故答案为 00。

在第二个样例中,存在以下 1212 条长度为 33 且起点与终点为同一城市的特殊路径:(1,2,4,1)(1, 2, 4, 1)、(1,3,4,1)(1, 3, 4, 1)、(1,4,2,1)(1, 4, 2, 1)、(1,4,3,1)(1, 4, 3, 1)、(2,1,4,2)(2, 1, 4, 2)、(2,4,1,2)(2, 4, 1, 2)、(3,1,4,3)(3, 1, 4, 3)、(3,4,1,3)(3, 4, 1, 3)、(4,1,3,4)(4, 1, 3, 4)、(4,3,1,4)(4, 3, 1, 4)、(4,1,2,4)(4, 1, 2, 4) 和 (4,2,1,4)(4, 2, 1, 4)。

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

首页