AT_ndpc2026_r.Triples

入门

通过率:0%

时间限制:3.50s

内存限制:1024MB

AC君温馨提醒

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

题目描述

For non-negative integers u,vu, v, we write u⊆vu \subseteq v to mean u OR v=vu\ \mathrm{OR}\ v = v. Here, OR\mathrm{OR} denotes the bitwise OR operation.

A sequence of triples of non-negative integers ((u1,v1,w1),(u2,v2,w2),…,(uk,vk,wk))((u_1,v_1,w_1),(u_2,v_2,w_2),\dots,(u_k,v_k,w_k)) is called a good sequence if it satisfies all of the following conditions:

  • k≥2k \geq 2.
  • For all integers ii such that 1≤i≤k−11 \leq i \leq k-1, it holds that ui⊆wi+1⊆viu_i \subseteq w_{i+1} \subseteq v_i.

You are given a sequence of triples A=((x1,y1,z1),(x2,y2,z2),…,(xN,yN,zN))A = ((x_1,y_1,z_1), (x_2,y_2,z_2), \dots, (x_N,y_N,z_N)).
For all ii such that 1≤i≤N1 \leq i \leq N, it holds that xi⊆yix_i \subseteq y_i.

There are 2N−N−12^N - N - 1 subsequences of AA with length at least 22 (counting different choices of indices separately).
Among them, find the number of good sequences, modulo 998244353998244353.

对于非负整数 u,vu, v,我们用记号 u⊆vu \subseteq v 表示 u OR v=vu\ \mathrm{OR}\ v = v,其中 OR\mathrm{OR} 表示按位或运算。

一个由非负整数三元组构成的序列 ((u1,v1,w1),(u2,v2,w2),…,(uk,vk,wk))((u_1,v_1,w_1),(u_2,v_2,w_2),\dots,(u_k,v_k,w_k)) 称为好序列,当且仅当它满足以下所有条件:

  • k≥2k \geq 2;
  • 对所有满足 1≤i≤k−11 \leq i \leq k-1 的整数 ii,均有 ui⊆wi+1⊆viu_i \subseteq w_{i+1} \subseteq v_i。

给定一个三元组序列 A=((x1,y1,z1),(x2,y2,z2),…,(xN,yN,zN))A = ((x_1,y_1,z_1), (x_2,y_2,z_2), \dots, (x_N,y_N,z_N))。
对所有满足 1≤i≤N1 \leq i \leq N 的 ii,均有 xi⊆yix_i \subseteq y_i。

序列 AA 共有 2N−N−12^N - N - 1 个长度至少为 22 的子序列(按索引的不同选择分别计数)。
在这些子序列中,求好序列的个数,并对 998244353998244353 取模。

输入格式

The input is given from standard input in the following format:

NN
x1x_1 y1y_1 z1z_1
x2x_2 y2y_2 z2z_2
⋮\vdots
xNx_N yNy_N zNz_N

输入从标准输入中按以下格式给出:

NN
x1x_1 y1y_1 z1z_1
x2x_2 y2y_2 z2z_2
⋮\vdots
xNx_N yNy_N zNz_N

输出格式

Print the number of good sequences that are subsequences of AA with length at least 22, modulo 998244353998244353.

输出 AA 的长度至少为 22 的“好序列”子序列的个数,对 998244353998244353 取模。

输入输出样例

  • 输入#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\max(x_i, y_i, z_i) < 2^{18} holds for every integer ii such that 1≤i≤N1 \leq i \leq N, you will get 44 points.

Sample 1 Explanation:
There are 22 sequences that satisfy the condition:

  • ((2,6,3),(1,5,2))((2,6,3),(1,5,2))
  • ((0,7,4),(1,5,2))((0,7,4),(1,5,2))

Constraints

  • 2≤N≤3×1052 \leq N \leq 3 \times 10^5
  • 0≤xi<2240 \leq x_i < 2^{24}
  • 0≤yi<2240 \leq y_i < 2^{24}
  • 0≤zi<2240 \leq z_i < 2^{24}
  • xi OR yi=yix_i \ \mathrm{OR}\ y_i = y_i
  • All input values are integers

部分得分

本题采用部分得分制。

  • 若你解决了满足对每个整数 ii(其中 1≤i≤N1 \leq i \leq N)均有 max⁡(xi,yi,zi)<218\max(x_i, y_i, z_i) < 2^{18} 的数据集,则可获得 44 分。

样例 1 解释:
共有 22 个序列满足条件:

  • ((2,6,3),(1,5,2))((2,6,3),(1,5,2))
  • ((0,7,4),(1,5,2))((0,7,4),(1,5,2))

约束条件

  • 2≤N≤3×1052 \leq N \leq 3 \times 10^5
  • 0≤xi<2240 \leq x_i < 2^{24}
  • 0≤yi<2240 \leq y_i < 2^{24}
  • 0≤zi<2240 \leq z_i < 2^{24}
  • xi OR yi=yix_i \ \mathrm{OR}\ y_i = y_i
  • 所有输入值均为整数

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

首页