AT_abc466_g.Segment Sum Constraints
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given M triples of integers (Li,Ri,Si).
Consider tuples A=(A1,A2,…,AN) of N positive integers satisfying all of the following conditions.
- The sum of ALi,ALi+1,…,ARi is Si.
If there are infinitely many tuples satisfying the conditions, output Infinity; otherwise, output the number of such tuples, modulo 998244353.
给你 M 个整数三元组 (Li,Ri,Si)。
考虑由 N 个正整数构成的元组 A=(A1,A2,…,AN),要求其满足以下所有条件:
- ALi+ALi+1+⋯+ARi=Si。
若满足条件的元组有无穷多个,则输出 Infinity;否则,输出满足条件的元组个数对 998244353 取模的结果。
输入格式
The input is given from Standard Input in the following format:
N M
L1 R1 S1
L2 R2 S2
⋮
LM RM SM
输入从标准输入中按以下格式给出:
N M
L1 R1 S1
L2 R2 S2
⋮
LM RM SM
输出格式
If there are infinitely many tuples satisfying the conditions, output Infinity; otherwise, output the number of such tuples, modulo 998244353.
如果满足条件的元组有无穷多个,则输出 Infinity;否则,输出满足条件的元组个数对 998244353 取模的结果。
输入输出样例
输入#1
3 2 1 2 7 2 3 10
输出#1
6
输入#2
2 1 1 1 10
输出#2
Infinity
输入#3
2 2 1 1 10 1 2 1
输出#3
0
说明/提示
Sample 1 Explanation:
We have the following two conditions.
- A1+A2=7
- A2+A3=10
The six tuples A=(1,6,4),(2,5,5),(3,4,6),(4,3,7),(5,2,8),(6,1,9) satisfy the conditions, so output 6 modulo 998244353, that is, output 6.
Sample 2 Explanation:
There are infinitely many tuples A satisfying the conditions.
Sample 3 Explanation:
There is no tuple A satisfying the conditions.
Constraints
- 1≤N≤8
- 1≤M≤36
- 1≤Li≤Ri≤N
- 1≤Si≤109
- All (Li,Ri) are distinct.
- All input values are integers.
样例 1 解释:
我们有以下两个条件:
- A1+A2=7
- A2+A3=10
满足条件的六元组 A=(1,6,4),(2,5,5),(3,4,6),(4,3,7),(5,2,8),(6,1,9) 共有 6 个,因此输出 6 对 998244353 取模的结果,即输出 6。
样例 2 解释:
满足条件的元组 A 有无穷多个。
样例 3 解释:
不存在满足条件的元组 A。
约束条件
- 1≤N≤8
- 1≤M≤36
- 1≤Li≤Ri≤N
- 1≤Si≤109
- 所有 (Li,Ri) 互不相同。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?