CF1679F.Formalism for Formalism

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Yura is a mathematician, and his cognition of the world is so absolute as if he have been solving formal problems a hundred of trillions of billions of years. This problem is just that!

Consider all non-negative integers from the interval [0,10n)[0, 10^{n}). For convenience we complement all numbers with leading zeros in such way that each number from the given interval consists of exactly nn decimal digits.

You are given a set of pairs (ui,vi)(u_i, v_i), where uiu_i and viv_i are distinct decimal digits from 00 to 99.

Consider a number xx consisting of nn digits. We will enumerate all digits from left to right and denote them as d1,d2,…,dnd_1, d_2, \ldots, d_n. In one operation you can swap digits did_i and di+1d_{i + 1} if and only if there is a pair (uj,vj)(u_j, v_j) in the set such that at least one of the following conditions is satisfied:

  1. di=ujd_i = u_j and di+1=vjd_{i + 1} = v_j,
  2. di=vjd_i = v_j and di+1=ujd_{i + 1} = u_j.

We will call the numbers xx and yy, consisting of nn digits, equivalent if the number xx can be transformed into the number yy using some number of operations described above. In particular, every number is considered equivalent to itself.

You are given an integer nn and a set of mm pairs of digits (ui,vi)(u_i, v_i). You have to find the maximum integer kk such that there exists a set of integers x1,x2,…,xkx_1, x_2, \ldots, x_k (0≤xi<10n0 \le x_i \lt 10^{n}) such that for each 1≤i<j≤k1 \le i \lt j \le k the number xix_i is not equivalent to the number xjx_j.

尤拉是一位数学家,他对世界的认知是如此绝对,仿佛他已经求解形式化问题长达百万万亿亿年。本题正是如此!

考虑区间 [0,10n)[0, 10^{n}) 内的所有非负整数。为方便起见,我们对所有数字在前面补零,使得该区间内的每个数恰好由 nn 位十进制数字组成。

给定一组数对 (ui,vi)(u_i, v_i),其中每个 uiu_i 和 viv_i 均为 00 到 99 之间互不相同的十进制数字。

考虑一个由 nn 位数字组成的数 xx。我们将从左到右依次对其各位数字编号,记为 d1,d2,…,dnd_1, d_2, \ldots, d_n。在一次操作中,当且仅当存在集合中的某个数对 (uj,vj)(u_j, v_j),使得以下任一条件成立时,才允许交换相邻的两位数字 did_i 和 di+1d_{i + 1}:

  1. di=ujd_i = u_j 且 di+1=vjd_{i + 1} = v_j,
  2. di=vjd_i = v_j 且 di+1=ujd_{i + 1} = u_j。

若可通过若干次上述操作将 nn 位数字组成的数 xx 变换为 nn 位数字组成的数 yy,则称 xx 与 yy 等价。特别地,每个数均视为与自身等价。

给定整数 nn 和 mm 对数字 (ui,vi)(u_i, v_i) 组成的集合。你需要找出最大的整数 kk,使得存在一组整数 x1,x2,…,xkx_1, x_2, \ldots, x_k(满足 0≤xi<10n0 \le x_i \lt 10^{n}),且对任意 1≤i<j≤k1 \le i \lt j \le k,均有 xix_i 与 xjx_j 不等价。

输入格式

The first line contains an integer nn (1≤n≤50 0001 \le n \le 50\,000) — the number of digits in considered numbers.

The second line contains an integer mm (0≤m≤450 \le m \le 45) — the number of pairs of digits in the set.

Each of the following mm lines contains two digits uiu_i and viv_i, separated with a space (0≤ui<vi≤90 \le u_i \lt v_i \le 9).

It's guaranteed that all described pairs are pairwise distinct.

第一行包含一个整数 nn(1≤n≤50 0001 \le n \le 50\,000)—— 表示所考虑数字的位数。

第二行包含一个整数 mm(0≤m≤450 \le m \le 45)—— 表示集合中数字对的个数。

接下来的 mm 行,每行包含两个数字 uiu_i 和 viv_i,以空格分隔(0≤ui<vi≤90 \le u_i \lt v_i \le 9)。

保证所有描述的数字对两两互不相同。

输出格式

Print one integer — the maximum value kk such that there exists a set of integers x1,x2,…,xkx_1, x_2, \ldots, x_k (0≤xi<10n0 \le x_i \lt 10^{n}) such that for each 1≤i<j≤k1 \le i \lt j \le k the number xix_i is not equivalent to the number xjx_j.

As the answer can be big enough, print the number kk modulo 998 244 353998\,244\,353.

输出一个整数——即最大的 kk 值,使得存在一组整数 x1,x2,…,xkx_1, x_2, \ldots, x_k(满足 0≤xi<10n0 \le x_i < 10^{n}),且对任意 1≤i<j≤k1 \le i < j \le k,均有 xix_i 与 xjx_j 不等价。

由于答案可能非常大,请输出 kk 对 998 244 353998\,244\,353 取模的结果。

输入输出样例

  • 输入#1

    1
    0

    输出#1

    10
  • 输入#2

    2
    1
    0 1

    输出#2

    99
  • 输入#3

    2
    9
    0 1
    1 2
    2 3
    3 4
    4 5
    5 6
    6 7
    7 8
    8 9

    输出#3

    91

说明/提示

In the first example we can construct a set that contains all integers from 00 to 99. It's easy to see that there are no two equivalent numbers in the set.

In the second example there exists a unique pair of equivalent numbers: 0101 and 1010. We can construct a set that contains all integers from 00 to 9999 despite number 11.

在第一个例子中,我们可以构造一个包含从 00 到 99 的所有整数的集合。显然,该集合中不存在两个等价的数。

在第二个例子中,存在唯一一对等价的数:0101 和 1010。尽管数字 11 存在,我们仍可构造一个包含从 00 到 9999 的所有整数的集合。

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

首页