CF1634F.Fibonacci Additions
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One of my most productive days was throwing away 1,000 lines of code.
— Ken Thompson
Fibonacci addition is an operation on an array X of integers, parametrized by indices l and r . Fibonacci addition increases Xl by F1 , increases Xl+1 by F2 , and so on up to Xr which is increased by Fr−l+1 .
Fi denotes the i -th Fibonacci number ( F1=1 , F2=1 , Fi=Fi−1+Fi−2 for i>2 ), and all operations are performed modulo MOD .
You are given two arrays A and B of the same length. We will ask you to perform several Fibonacci additions on these arrays with different parameters, and after each operation you have to report whether arrays A and B are equal modulo MOD .
输入格式
The first line contains 3 numbers n , q and MOD ( 1≤n,q≤3⋅105,1≤MOD≤109+7 ) — the length of the arrays, the number of operations, and the number modulo which all operations are performed.
The second line contains n numbers — array A ( 0≤Ai<MOD ).
The third line also contains n numbers — array B ( 0≤Bi<MOD ).
The next q lines contain character c and two numbers l and r ( 1≤l≤r≤n ) — operation parameters. If c is "A", Fibonacci addition is to be performed on array A , and if it is is "B", the operation is to be performed on B .
输出格式
After each operation, print "YES" (without quotes) if the arrays are equal and "NO" otherwise. Letter case does not matter.
输入输出样例
输入#1
3 5 3 2 2 1 0 0 0 A 1 3 A 1 3 B 1 1 B 2 2 A 3 3
输出#1
YES NO NO NO YES
输入#2
5 3 10 2 5 0 3 5 3 5 8 2 5 B 2 3 B 3 4 A 1 2
输出#2
NO NO YES
说明/提示
Explanation of the test from the condition:
- Initially A=[2,2,1] , B=[0,0,0] .
- After operation "A 1 3": A=[0,0,0] , B=[0,0,0] (addition is modulo 3).
- After operation "A 1 3": A=[1,1,2] , B=[0,0,0] .
- After operation "B 1 1": A=[1,1,2] , B=[1,0,0] .
- After operation "B 2 2": A=[1,1,2] , B=[1,1,0] .
- After operation "A 3 3": A=[1,1,0] , B=[1,1,0] .