CF1148H.Holy Diver
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array which is initially empty. You need to perform n operations of the given format:
- "a l r k": append a to the end of the array. After that count the number of integer pairs x,y such that l≤x≤y≤r and mex(ax,ax+1,…,ay)=k.
The elements of the array are numerated from 1 in the order they are added to the array.
To make this problem more tricky we don't say your real parameters of the queries. Instead your are given a′, l′, r′, k′. To get a, l, r, k on the i-th operation you need to perform the following:
- a:=(a′+lans)mod(n+1),
- l:=(l′+lans)modi+1,
- r:=(r′+lans)modi+1,
- if l>r swap l and r,
- k:=(k′+lans)mod(n+1),
where lans is the answer to the previous operation, initially lans is equal to zero. i is the id of the operation, operations are numbered from 1.
The mex(S), where S is a multiset of non-negative integers, is the smallest non-negative integer which does not appear in the set. For example, mex(2,2,3)=0 and mex(0,1,4,1,6)=2.
你将获得一个初始为空的数组。你需要执行 n 次如下格式的操作:
- “a l r k”:将 a 追加到数组末尾;随后统计满足 l≤x≤y≤r 且 mex(ax,ax+1,…,ay)=k 的整数对 (x,y) 的个数。
数组元素从 1 开始编号,编号顺序即其被加入数组的顺序。
为使本题更具挑战性,我们不直接给出查询的真实参数,而是提供 a′、l′、r′、k′。对于第 i 次操作,需按如下方式计算真实参数 a、l、r、k:
- a:=(a′+lans)mod(n+1),
- l:=(l′+lans)modi+1,
- r:=(r′+lans)modi+1,
- 若 l>r,则交换 l 与 r,
- k:=(k′+lans)mod(n+1),
其中 lans 表示上一次操作的答案;初始时(即第一次操作前)lans=0;i 表示当前操作的编号,操作编号从 1 开始。
mex(S) 表示非负整数多重集 S 的最小未出现非负整数(minimum excluded value)。例如,mex({2,2,3})=0,而 mex({0,1,4,1,6})=2。
输入格式
The first line contains a single integer n (1≤n≤2⋅105) — the length of the array.
The next n lines contain the description of queries.
Each of them n lines contains four non-negative integers a′, l′, r′, k′ (0,≤a′,l′,r′,k′≤109), describing one operation.
第一行包含一个整数 n(1≤n≤2⋅105)—— 数组的长度。
接下来的 n 行描述了查询操作。
每行包含四个非负整数 a′、l′、r′、k′(0≤a′,l′,r′,k′≤109),描述一次操作。
输出格式
For each query print a single integer — the answer to this query.
对于每个查询,输出一个整数——该查询的答案。
输入输出样例
输入#1
5 0 0 0 1 0 1 0 5 5 2 1 0 5 2 1 0 2 4 3 3
输出#1
1 1 2 6 3
输入#2
5 2 0 0 2 2 0 1 1 0 0 2 0 3 2 2 0 0 2 3 0
输出#2
0 0 3 0 0
说明/提示
For the first example the decoded values of a, l, r, k are the following:
a1=0,l1=1,r1=1,k1=1
a2=1,l2=1,r2=2,k2=0
a3=0,l3=1,r3=3,k3=1
a4=1,l4=1,r4=4,k4=2
a5=2,l5=1,r5=5,k5=3
For the second example the decoded values of a, l, r, k are the following:
a1=2,l1=1,r1=1,k1=2
a2=2,l2=1,r2=2,k2=1
a3=0,l3=1,r3=3,k3=0
a4=0,l4=2,r4=2,k4=3
a5=0,l5=3,r5=4,k5=0
第一个样例中,a、l、r、k 的解码值如下:
a1=0,l1=1,r1=1,k1=1
a2=1,l2=1,r2=2,k2=0
a3=0,l3=1,r3=3,k3=1
a4=1,l4=1,r4=4,k4=2
a5=2,l5=1,r5=5,k5=3
第二个样例中,a、l、r、k 的解码值如下:
a1=2,l1=1,r1=1,k1=2
a2=2,l2=1,r2=2,k2=1
a3=0,l3=1,r3=3,k3=0
a4=0,l4=2,r4=2,k4=3
a5=0,l5=3,r5=4,k5=0
输入解题思路,AI测评打分。不知道怎么写?