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

21948번 - The Grade 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB111100.000%

문제

AlekuKebap is in his math class. While he tries to figure out why 1+1=2, his teacher was writing on the board a slightly more complicated problem. There are given Q queries and a list S with P elemnts equal with 0. Let A be initially an empty set. The querries can be:

  • 0 x (insert value x in set A)
  • 1 x (erase the value x from set A, it is guaranteed that the value x exists in set A)

It is guaranteed that A will never be empty after a query. After every query, the teacher asks Aleku the following question: can I arrange in list S all elements from the set A (not necessary in the order from the A) so that:

  • Elements form A will be put on distinct standings, the rest being occupied by P elements equal with 0
  • Let S[i] be a positive element from S and S[j] the closest positive element from S that is located to the left of S[i], then the following condition mus be respected: i-j ≥ S[i].
  • Let f be the first positive element from the left of S, then f ≥ S[f].

If the answer to this question is yes, then find how many different configurations can be obtained. Because the answer can be very big, print the answer modulo 1,000,000,007.If the answer is no, print -1.

Help AlekuKebap to answer correctly to all teacher’s questions to recive a 10 grade.

입력

The first line contains two integers Q and P.

The next Q lines contain the description of every query.

출력

Every line will contain the answer to every question from the Q questions.

제한

  • Q ≤ 100,000
  • P ≤ 100,000
  • All numbers that will be added in the set are ≤ 1,000,000.

예제 입력 1

9 8
0 3
0 3
0 2
1 2
0 1
0 1
0 1
1 3
1 1

예제 출력 1

6
6
3
6
12
6
-1
60
60

힌트

출처

Contest > infO(1) Cup > infO(1) Cup 2018 National Round 4번

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

출처

대학교 대회

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

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