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

32485번 - Interference 다국어

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

문제

Physics can be so much fun! Yesterday, your teacher explained how interference works: If you have two waves, their heights add up over the whole waves' length! So if both waves have a peak, the resulting peak will be even higher. Likewise, if both waves have a wave trough below the water surface, the resulting wave has a trough that will be even further below. Technically, a wave's height is called amplitude and the distance between two wave peaks is called wavelength.

Today, your physics teacher describes the setup of an experiment she is about to perform. She will create stationary waves in a one-dimensional container of water. Due to her superior control over physical elements, all waves will have a precisely controlled amplitude and will only be created in an interval of given length. % travel in one direction for a given length. The wavelength of each wave is always 4ドル$ and the first positive peak will always be at the first index of the interval. We only measure the wave's amplitude at integer points. For example, a wave with amplitude 2ドル$ and length 9ドル$ can be described as 2 0 -2 0 2 0 -2 0 2. If there is no wave at a point, the amplitude is 0ドル$. Your task is to predict how high the resulting wave will be at given points in the container taking into account all the waves that were created up to that point.

Figure I.1: Interference of three waves in Sample Input 2. The black dots represent the resulting wave's height.

입력

The input consists of:

  • One line with two integers $n$ and $w$ (1ドル \le n \le 4,000円,ドル 1ドル \le w \le 10^{9}$), the number of lines and the width of the container.
  • $n$ lines, each containing either a wave description or a prediction task:
    • "! $p$ $\ell$ $a$", a wave description with starting position $p,ドル length $\ell$ $(1 \le p, \ell \le w),ドル and amplitude $a$ $(1 \le a \le 10^9)$. It is guaranteed that $p+\ell - 1 \le w$.
    • "? $p$", a prediction task for the resulting wave at position $p$ (1ドル \le p \le w$).

See Figure I.1 for a partial visualization of Sample 2.

출력

For each prediction task, output a line with a single integer, the height of the wave resulting from all former described waves at the requested position.

제한

예제 입력 1

4 10
! 2 7 1
? 9
? 7
? 6

예제 출력 1

0
0
1

예제 입력 2

7 10
! 2 6 1
! 3 8 2
! 5 2 3
? 6
! 5 5 4
? 8
? 9

예제 출력 2

1
0
2

예제 입력 3

6 12
! 1 7 1
! 7 3 2
? 6
? 7
? 8
? 10

예제 출력 3

0
1
0
0

예제 입력 4

6 11
! 1 6 1
? 6
! 5 7 4
? 6
! 6 3 2
? 6

예제 출력 4

0
0
2

힌트

출처

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

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

출처

대학교 대회

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

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