8613: Jobs (Easy Version)

内存限制:512 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Note: The only difference between the easy and the hard version is the constraints on nnn and mim_imi.

Since Little Horse gets a golden prize in a programming contest, many companies send offers to him. There are nnn companies, and the iii-th company has mim_imi available jobs. To get an offer from a company, you need to be qualified for the job.

How to be qualified? The company will test your "three quotients": IQ (Intelligence Quotient), EQ (Emotional Quotient), and AQ (Adversity Quotient). Each job has three lower limits of the three quotients respectively. If all of your IQ, EQ, and AQ are no less than the corresponding lower limits, you are qualified for the job. As long as you are qualified for at least one job in a company, the company will send an offer to you.

Little Horse's three quotients are all high enough, so all the companies send offers to him. But Little Horse has qqq friends that worry about their jobs. Given the value of IQ, EQ and AQ of each friend, Little Horse wants to know how many companies will send offers to each friend.

In this problem, the IQEQ, and AQ of these qqq friends are generated as below.
First, register an mt19937\texttt{mt19937}mt19937 random engine rng\texttt{rng}rng with the seed\texttt{seed}seed and a uniform integer distribution object.
#include <random>
std::mt19937 rng(seed);
std::uniform_int_distribution<> u(1,400);
Then, the value of IQ, EQ, and AQ are generated as follows.
int lastans=0;
for (int i=1;i<=q;i++)
{
    int IQ=(u(rng)^lastans)%400+1;  // The IQ of the i-th friend
    int EQ=(u(rng)^lastans)%400+1;  // The EQ of the i-th friend
    int AQ=(u(rng)^lastans)%400+1;  // The AQ of the i-th friend
    lastans=solve(IQ,EQ,AQ);  // The answer to the i-th friend
}

输入格式

The first line of input contains two integers n,qn,qn,q (1≤n≤101 \le n \le 101n10, 1≤q≤2×1061 \le q \le 2\times 10^61q2×106), indicating the number of companies and Little Horse's friends.
Then in the next nnn lines, the first integer of the iii-th line is mim_imi (1≤mi≤1051 \le m_i \le 10^51mi105) --- the number of jobs in the iii-th company. Then there follow 3mi3m_i3mi integers. The jjj-th triple integers aj,bj,cja_j,b_j,c_jaj,bj,cj (1≤aj,bj,cj≤4001 \le a_j,b_j,c_j \le 4001aj,bj,cj400) indicate the lower limits of IQ, EQ, and AQ for the jjj-th job in the iii-th company.
The next line contains one integer seed\text{seed}seed (108≤seed<23110^8\le \text{seed}<2^{31}108seed<231). Then the IQ ,EQ, and AQ of these qqq friends are generated as above.

输出格式

Let's denote the answer to the iii-th friend as ansi\text{ans}_iansi. You should output:
(∑i=1qansi⋅seedq−i)mod998244353\left( \sum_{i=1}^q\text{ans}_i\cdot\text{seed}^{q-i} \right) \bmod 998244353(i=1qansiseedqi)mod998244353
in a single line.

输入样例 复制

3 5
2 1 1 2 2 1 2
3 1 3 2 2 3 1 2 3 3
2 2 3 1 3 2 1
191415411

输出样例 复制

34417749

数据范围与提示

The value of IQ, EQ, and AQ of the 55 friends in example are shown as follows.

92 108 303
116 36 265
255 132 185
360 219 272
8 115 254

The answers to each friend are all 33.

分类标签