PAST4L
PAST4L
Thoughts.
Answer the number of adjacent value matches each time by adding to one of the following: odd, even, or one point.
Since the query is 10^5, per query is a constant or log
One point change is okay, but odd numbers are a problem.
If you have an even-numbered minus an odd-numbered difference, it is just a Range Add.
Range Add to find the number of 0's in the whole?
Don't Range Add, just look for the -x ones.
Constant order if you can have the frequency table in an array.
10^9, so it's impossible.
Can we use hash?
What do you do when you renew a point?
calculate backwards
AC
code:python
def main():
N, Q = map(int, input().split())
HS = list(map(int, input().split()))
from collections import defaultdict
freq = defaultdict(int)
for i in range(N - 1):
d = HSi - HSi + 1 # odd - even if i & 1:
d = -d
odd_height = 0
for _q in range(Q):
q = list(map(int, input().split()))
else:
if i > 0:
if i & 1:
d = -d
if i < N - 1:
if i & 1:
d = -d
if i > 0:
if i & 1:
d = -d
if i < N - 1:
if i & 1:
d = -d
---
This page is auto-translated from /nishio/PAST4L. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.