Logo
(追記) (追記ここまで)

32480번 - Dark Alley 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB105494043.956%

문제

One cold and foggy night, you walk down a shady alley. There should be a lamp every few metres but none of them seem to work, and in this night, not even the moon enlightens your path. Alone and in the dark, you wonder: "Even if there was a working lamp somewhere, how much would it lighten my way?". Now, back at home, you want to calculate this.

The alley can be modelled as a line with a length of $n$ metres. The fog has a uniform density and reduces the light of a lamp by a factor of 1ドル-p$ every metre. The brightness at one point is the sum of the light that reaches this point from every lamp. You want to calculate this brightness at some points after placing some lamps.

입력

The input consists of:

  • One line with two integers $n$ and $q$ and one real number $p$ (1ドル\leq n, q\leq 2\cdot10^5, 0 < p < 1$), the length of the alley, the number of queries and the density of the fog. The density $p$ of the fog will be given with at most 6ドル$ digits behind the decimal point.
  • $q$ lines containing one of three query types:
    1. "+ b x" given two integers $b$ and $x$ (1ドル\leq b \leq 10^9$ and 1ドル\leq x \leq n$), place a lamp with brightness $b$ at position $x$.
    2. "- b x" given integers $b$ and $x$ (1ドル\leq b \leq 10^9$ and 1ドル\leq x \leq n$), remove a lamp with brightness $b$ at position $x$. It is guaranteed that a lamp with that brightness was placed there earlier.
    3. "? x" given one integer $x$ (1ドル\leq x \leq n$), calculate the brightness at position $x$.

출력

It can be shown that the brightness can be calculated as a fraction $\frac{P}{Q}$ where $Q$ is not divisible by 10ドル^9+7$. For each query of type "?", print the brightness as $P\cdot Q^{-1} \bmod 10^9+7$ in a single line.

제한

예제 입력 1

5 6 0.25
+ 4 2
? 1
? 2
? 3
? 4
? 5

예제 출력 1

3
4
3
250000004
187500003

The brightness in the alley after placing the lamp will look like this:

3 4 3 2.25 1.6875

예제 입력 2

5 7 0.33
+ 9 1
? 5
+ 4 3
? 2
? 5
- 9 1
? 2

예제 출력 2

312342734
470000012
341542736
760000008

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2024 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /