309445: CF1679F. Formalism for Formalism

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Formalism for Formalism

题意翻译

### 题意简述 给出正整数 $n$,所有不足 $n$ 位(十进制)的数用前导零补充。 给出 $m$ 组**无序**数对 $(u_i,v_i)$,若一个数字的相邻两位数 $x,y$ 满足 $(x,y)$ 存在于这 $m$ 组数对中,则可以交换 $x,y$ 的位置。若 $A$ 可以通过若干次(包含零次)交换得到 $B$,则认为 $A$ 和 $B$ 是等价的。 求出最大整数 $k$,使得存在一组非负整数 $x_1,x_2,\ldots,x_k(0\leq x_i<10^n)$ 满足对于任意 $1\leq i<j\leq k$,$x_i$ 与 $x_j$ 不等价。 ### 输入格式 第一行一个整数 $n(1\leq n\leq 50000)$,含义如题面所述。 第二行一个整数 $m(0\leq m\leq 45)$,表示数对数。 接下来 $m$ 行,每行一个无序数对 $(u_i,v_i)(0\leq u_i,v_i\leq 9)$,保证任意两组数对不相同。 ### 输出格式 输出一个整数 $k$,含义如题面所述。 由于答案可能会很大,你需要输出答案对 $998244353$ 取模的值。

题目描述

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, 10^{n}) $ . For convenience we complement all numbers with leading zeros in such way that each number from the given interval consists of exactly $ n $ decimal digits. You are given a set of pairs $ (u_i, v_i) $ , where $ u_i $ and $ v_i $ are distinct decimal digits from $ 0 $ to $ 9 $ . Consider a number $ x $ consisting of $ n $ digits. We will enumerate all digits from left to right and denote them as $ d_1, d_2, \ldots, d_n $ . In one operation you can swap digits $ d_i $ and $ d_{i + 1} $ if and only if there is a pair $ (u_j, v_j) $ in the set such that at least one of the following conditions is satisfied: 1. $ d_i = u_j $ and $ d_{i + 1} = v_j $ , 2. $ d_i = v_j $ and $ d_{i + 1} = u_j $ . We will call the numbers $ x $ and $ y $ , consisting of $ n $ digits, equivalent if the number $ x $ can be transformed into the number $ y $ using some number of operations described above. In particular, every number is considered equivalent to itself. You are given an integer $ n $ and a set of $ m $ pairs of digits $ (u_i, v_i) $ . You have to find the maximum integer $ k $ such that there exists a set of integers $ x_1, x_2, \ldots, x_k $ ( $ 0 \le x_i < 10^{n} $ ) such that for each $ 1 \le i < j \le k $ the number $ x_i $ is not equivalent to the number $ x_j $ .

输入输出格式

输入格式


The first line contains an integer $ n $ ( $ 1 \le n \le 50\,000 $ ) — the number of digits in considered numbers. The second line contains an integer $ m $ ( $ 0 \le m \le 45 $ ) — the number of pairs of digits in the set. Each of the following $ m $ lines contains two digits $ u_i $ and $ v_i $ , separated with a space ( $ 0 \le u_i < v_i \le 9 $ ). It's guaranteed that all described pairs are pairwise distinct.

输出格式


Print one integer — the maximum value $ k $ such that there exists a set of integers $ x_1, x_2, \ldots, x_k $ ( $ 0 \le x_i < 10^{n} $ ) such that for each $ 1 \le i < j \le k $ the number $ x_i $ is not equivalent to the number $ x_j $ . As the answer can be big enough, print the number $ k $ modulo $ 998\,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 $ 0 $ to $ 9 $ . 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: $ 01 $ and $ 10 $ . We can construct a set that contains all integers from $ 0 $ to $ 99 $ despite number $ 1 $ .

Input

题意翻译

### 题意简述 给出正整数 $n$,所有不足 $n$ 位(十进制)的数用前导零补充。 给出 $m$ 组**无序**数对 $(u_i,v_i)$,若一个数字的相邻两位数 $x,y$ 满足 $(x,y)$ 存在于这 $m$ 组数对中,则可以交换 $x,y$ 的位置。若 $A$ 可以通过若干次(包含零次)交换得到 $B$,则认为 $A$ 和 $B$ 是等价的。 求出最大整数 $k$,使得存在一组非负整数 $x_1,x_2,\ldots,x_k(0\leq x_i<10^n)$ 满足对于任意 $1\leq i<j\leq k$,$x_i$ 与 $x_j$ 不等价。 ### 输入格式 第一行一个整数 $n(1\leq n\leq 50000)$,含义如题面所述。 第二行一个整数 $m(0\leq m\leq 45)$,表示数对数。 接下来 $m$ 行,每行一个无序数对 $(u_i,v_i)(0\leq u_i,v_i\leq 9)$,保证任意两组数对不相同。 ### 输出格式 输出一个整数 $k$,含义如题面所述。 由于答案可能会很大,你需要输出答案对 $998244353$ 取模的值。

Output

题目大意:
给定一个正整数 \( n \),所有不足 \( n \) 位的数用前导零补充。给定 \( m \) 组无序数对 \((u_i,v_i)\),如果数字的相邻两位 \( x, y \) 满足 \((x,y)\) 存在于这 \( m \) 组数对中,则可以交换 \( x, y \) 的位置。如果 \( A \) 可以通过若干次(包含零次)交换得到 \( B \),则认为 \( A \) 和 \( B \) 是等价的。求出最大整数 \( k \),使得存在一组非负整数 \( x_1, x_2, \ldots, x_k \)(\( 0 \leq x_i < 10^n \)) 满足对于任意 \( 1 \leq i < j \leq k \),\( x_i \) 与 \( x_j \) 不等价。

输入格式:
第一行一个整数 \( n \)(\( 1 \leq n \leq 50000 \)),含义如题面所述。
第二行一个整数 \( m \)(\( 0 \leq m \leq 45 \)),表示数对数。
接下来 \( m \) 行,每行一个无序数对 \((u_i,v_i)\)(\( 0 \leq u_i, v_i \leq 9 \)),保证任意两组数对不相同。

输出格式:
输出一个整数 \( k \),含义如题面所述。由于答案可能会很大,你需要输出答案对 \( 998244353 \) 取模的值。

题目描述:
Yura 是一个数学家,他对世界的认知是如此绝对,就像他已经解决了几百亿亿年的形式问题。这个问题正是如此!

考虑所有非负整数,从区间 \( [0, 10^n) \) 中。为了方便,我们用前导零补充所有数字,使得给定区间中的每个数字恰好由 \( n \) 个十进制数字组成。

给你一个数对集合 \((u_i, v_i)\),其中 \( u_i \) 和 \( v_i \) 是从 0 到 9 的不同十进制数字。

考虑一个由 \( n \) 位数字组成的数 \( x \)。我们将从左到右枚举所有数字,并将它们表示为 \( d_1, d_2, \ldots, d_n \)。在一次操作中,你可以交换数字 \( d_i \) 和 \( d_{i + 1} \),当且仅当集合中存在一个数对 \((u_j, v_j)\),使得以下条件之一成立:

1. \( d_i = u_j \) 且 \( d_{i + 1} = v_j \),
2. \( d_i = v_j \) 且 \( d_{i + 1} = u_j \)。

如果数字 \( x \) 可以通过上述操作转换为数字 \( y \),我们将称数字 \( x \) 和 \( y \) 为等价的。特别是,每个数字都认为与其自身等价。

给你一个整数 \( n \) 和一个包含 \( m \) 对数字的集合 \((u_i, v_i)\)。你需要找到最大的整数 \( k \),使得存在一个整数集合 \( x_1, x_2, \ldots, x_k \)(\( 0 \le x_i < 10^n \)),使得对于每个 \( 1 \le i < j \le k \),数字 \( x_i \) 不等价于 \( x_j \)。

输入输出格式:
输入格式:
第一行包含一个整数 \( n \)(\( 1 \le n \le 50,000 \)) — 考虑的数字中的数字位数。
第二行包含一个整数 \( m \)(\( 0 \le m \le 45 \)) — 集合中数字对的个数。
接下来的 \( m \) 行,每行包含用空格分隔的两个数字 \( u_i \) 和 \( v_i \)(\( 0 \le u_i < v_i \le 9 \))。
保证所有描述的数对都是两两不同的。

输出格式:
打印一个整数 — \( k \) 的最大值,使得存在一个整数集合 \( x_1, x_2, \ldots, x_k \)(\( 0 \le x_i < 10^n \)),使得对于每个 \( 1 \le i < j \le k \),数字 \( x_i \) 不等价于 \( x_j \)。

答案可能很大,因此请打印 \( k \) 对 \( 998,244,353 \) 取模的值。题目大意: 给定一个正整数 \( n \),所有不足 \( n \) 位的数用前导零补充。给定 \( m \) 组无序数对 \((u_i,v_i)\),如果数字的相邻两位 \( x, y \) 满足 \((x,y)\) 存在于这 \( m \) 组数对中,则可以交换 \( x, y \) 的位置。如果 \( A \) 可以通过若干次(包含零次)交换得到 \( B \),则认为 \( A \) 和 \( B \) 是等价的。求出最大整数 \( k \),使得存在一组非负整数 \( x_1, x_2, \ldots, x_k \)(\( 0 \leq x_i < 10^n \)) 满足对于任意 \( 1 \leq i < j \leq k \),\( x_i \) 与 \( x_j \) 不等价。 输入格式: 第一行一个整数 \( n \)(\( 1 \leq n \leq 50000 \)),含义如题面所述。 第二行一个整数 \( m \)(\( 0 \leq m \leq 45 \)),表示数对数。 接下来 \( m \) 行,每行一个无序数对 \((u_i,v_i)\)(\( 0 \leq u_i, v_i \leq 9 \)),保证任意两组数对不相同。 输出格式: 输出一个整数 \( k \),含义如题面所述。由于答案可能会很大,你需要输出答案对 \( 998244353 \) 取模的值。 题目描述: Yura 是一个数学家,他对世界的认知是如此绝对,就像他已经解决了几百亿亿年的形式问题。这个问题正是如此! 考虑所有非负整数,从区间 \( [0, 10^n) \) 中。为了方便,我们用前导零补充所有数字,使得给定区间中的每个数字恰好由 \( n \) 个十进制数字组成。 给你一个数对集合 \((u_i, v_i)\),其中 \( u_i \) 和 \( v_i \) 是从 0 到 9 的不同十进制数字。 考虑一个由 \( n \) 位数字组成的数 \( x \)。我们将从左到右枚举所有数字,并将它们表示为 \( d_1, d_2, \ldots, d_n \)。在一次操作中,你可以交换数字 \( d_i \) 和 \( d_{i + 1} \),当且仅当集合中存在一个数对 \((u_j, v_j)\),使得以下条件之一成立: 1. \( d_i = u_j \) 且 \( d_{i + 1} = v_j \), 2. \( d_i = v_j \) 且 \( d_{i + 1} = u_j \)。 如果数字 \( x \) 可以通过上述操作转换为数字 \( y \),我们将称数字 \( x \) 和 \( y \) 为等价的。特别是,每个数字都认为与其自身等价。 给你一个整数 \( n \) 和一个包含 \( m \) 对数字的集合 \((u_i, v_i)\)。你需要找到最大的整数 \( k \),使得存在一个整数集合 \( x_1, x_2, \ldots, x_k \)(\( 0 \le x_i < 10^n \)),使得对于每个 \( 1 \le i < j \le k \),数字 \( x_i \) 不等价于 \( x_j \)。 输入输出格式: 输入格式: 第一行包含一个整数 \( n \)(\( 1 \le n \le 50,000 \)) — 考虑的数字中的数字位数。 第二行包含一个整数 \( m \)(\( 0 \le m \le 45 \)) — 集合中数字对的个数。 接下来的 \( m \) 行,每行包含用空格分隔的两个数字 \( u_i \) 和 \( v_i \)(\( 0 \le u_i < v_i \le 9 \))。 保证所有描述的数对都是两两不同的。 输出格式: 打印一个整数 — \( k \) 的最大值,使得存在一个整数集合 \( x_1, x_2, \ldots, x_k \)(\( 0 \le x_i < 10^n \)),使得对于每个 \( 1 \le i < j \le k \),数字 \( x_i \) 不等价于 \( x_j \)。 答案可能很大,因此请打印 \( k \) 对 \( 998,244,353 \) 取模的值。

加入题单

算法标签: