AT_ndpc2026_r.Triples
入门
通过率:0%
时间限制:3.50s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For non-negative integers u,v, we write u⊆v to mean u OR v=v. Here, OR denotes the bitwise OR operation.
A sequence of triples of non-negative integers ((u1,v1,w1),(u2,v2,w2),…,(uk,vk,wk)) is called a good sequence if it satisfies all of the following conditions:
- k≥2.
- For all integers i such that 1≤i≤k−1, it holds that ui⊆wi+1⊆vi.
You are given a sequence of triples A=((x1,y1,z1),(x2,y2,z2),…,(xN,yN,zN)).
For all i such that 1≤i≤N, it holds that xi⊆yi.
There are 2N−N−1 subsequences of A with length at least 2 (counting different choices of indices separately).
Among them, find the number of good sequences, modulo 998244353.
对于非负整数 u,v,我们用记号 u⊆v 表示 u OR v=v,其中 OR 表示按位或运算。
一个由非负整数三元组构成的序列 ((u1,v1,w1),(u2,v2,w2),…,(uk,vk,wk)) 称为好序列,当且仅当它满足以下所有条件:
- k≥2;
- 对所有满足 1≤i≤k−1 的整数 i,均有 ui⊆wi+1⊆vi。
给定一个三元组序列 A=((x1,y1,z1),(x2,y2,z2),…,(xN,yN,zN))。
对所有满足 1≤i≤N 的 i,均有 xi⊆yi。
序列 A 共有 2N−N−1 个长度至少为 2 的子序列(按索引的不同选择分别计数)。
在这些子序列中,求好序列的个数,并对 998244353 取模。
输入格式
The input is given from standard input in the following format:
N
x1 y1 z1
x2 y2 z2
⋮
xN yN zN
输入从标准输入中按以下格式给出:
N
x1 y1 z1
x2 y2 z2
⋮
xN yN zN
输出格式
Print the number of good sequences that are subsequences of A with length at least 2, modulo 998244353.
输出 A 的长度至少为 2 的“好序列”子序列的个数,对 998244353 取模。
输入输出样例
输入#1
3 2 6 3 0 7 4 1 5 2
输出#1
2
输入#2
8 0 9 5 0 16 3 0 8 4 0 5 23 0 20 29 0 12 26 0 6 0 0 19 8
输出#2
9
输入#3
13 0 16777215 14827221 8390656 12582911 5535137 4325888 16711679 2641072 8849409 16776703 15212885 8389632 16514814 9612654 0 12517373 13419138 0 16777215 5271292 14464 16236535 6997452 131072 15727483 10218943 16 16646111 15524257 1181961 14647295 5595336 8388768 16775147 5472548 0 16777215 297940
输出#3
34
说明/提示
Partial Score
This problem has partial scoring.
- If you solve the dataset where max(xi,yi,zi)<218 holds for every integer i such that 1≤i≤N, you will get 4 points.
Sample 1 Explanation:
There are 2 sequences that satisfy the condition:
- ((2,6,3),(1,5,2))
- ((0,7,4),(1,5,2))
Constraints
- 2≤N≤3×105
- 0≤xi<224
- 0≤yi<224
- 0≤zi<224
- xi OR yi=yi
- All input values are integers
部分得分
本题采用部分得分制。
- 若你解决了满足对每个整数 i(其中 1≤i≤N)均有 max(xi,yi,zi)<218 的数据集,则可获得 4 分。
样例 1 解释:
共有 2 个序列满足条件:
- ((2,6,3),(1,5,2))
- ((0,7,4),(1,5,2))
约束条件
- 2≤N≤3×105
- 0≤xi<224
- 0≤yi<224
- 0≤zi<224
- xi OR yi=yi
- 所有输入值均为整数
输入解题思路,AI测评打分。不知道怎么写?