포럼
문제 ICPC00386

I. Interference

설명

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. 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.

제약
입력 형식

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\).
- A wave is described by "!\(~p~\ell~a\)", (\(1 \le p, \ell \le w\), \(1 \le a \le 10^9\)) the starting position, length, and amplitude of the wave.
- "?\(~p\)", a prediction task for the resulting wave at position \(p\) (\(1 \le p \le w\)).

See Figure 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
출력
0
0
1
예제 2
입력
7 10
! 2 6 1
! 3 8 2
! 5 2 3
? 6
! 5 5 4
? 8
? 9
출력
1
0
2
예제 3
입력
6 12
! 1 7 1
! 7 3 2
? 6
? 7
? 8
? 10
출력
0
1
0
0
예제 4
입력
6 11
! 1 6 1
? 6
! 5 7 4
? 6
! 6 3 2
? 6
출력
0
0
2
문제 정보

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

출처 ICPC GCPC 2024

평가 및 의견

I. Interference

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

Log in to rate problems.

개별 의견

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

풀이 제출

I. Interference

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