区间和约束AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given $M$ triples of integers $(L_i,R_i,S_i)$.
Consider tuples $A=(A_1,A_2,\ldots,A_N)$ of $N$ positive integers satisfying all of the following conditions.
给定 $M$ 个整数三元组 $(L_i,R_i,S_i)$。
考虑由 $N$ 个正整数组成的元组 $A=(A_1,A_2,\ldots,A_N)$,并满足以下所有条件。AI (CI翻译)
- The sum of
$A_{L_i}, A_{L_i+1}, \ldots, A_{R_i}$is$S_i$.
$A_{L_i}, A_{L_i+1}, \ldots, A_{R_i}$的和为$S_i$。
If there are infinitely many tuples satisfying the conditions, output Infinity; otherwise, output the number of such tuples, modulo $998244353$.
如果满足条件的元组有无限多个,输出 Infinity;否则,输出满足条件的元组数量对 $998244353$ 取模后的结果。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \leq N \leq 8$$1 \leq M \leq 36$$1\leq L_i\leq R_i\leq N$$1\leq S_i\leq 10^9$- All
$(L_i,R_i)$are distinct. - All input values are integers.
$1 \leq N \leq 8$$1 \leq M \leq 36$$1\leq L_i\leq R_i\leq N$$1\leq S_i\leq 10^9$- 所有
$(L_i,R_i)$均不相同。 - 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N M
L_1 R_1 S_1
L_2 R_2 S_2
\vdots
L_M R_M S_M
N M
L_1 R_1 S_1
L_2 R_2 S_2
\vdots
L_M R_M S_MAI (CI翻译)
Output
输出格式
AI (CI翻译)If there are infinitely many tuples satisfying the conditions, output Infinity; otherwise, output the number of such tuples, modulo $998244353$.
如果满足条件的元组有无限多个,输出 Infinity;否则,输出满足条件的元组数量对 $998244353$ 取模后的结果。AI (CI翻译)
样例
3 2
1 2 7
2 3 10
6
2 1
1 1 10
Infinity
2 2
1 1 10
1 2 1
0
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。