포럼
문제 ICPC00384

D. Dark Alley

설명

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:

[leftmargin=4em, topsep=0pt]
- 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\).
- 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.
- 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
출력
3
4
3
250000004
187500003
예제 2
입력
5 7 0.33
+ 9 1
? 5
+ 4 3
? 2
? 5
- 9 1
? 2
출력
312342734
470000012
341542736
760000008
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC GCPC 2024

평가 및 의견

D. Dark Alley

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

D. Dark Alley

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8