Friends | 프로그래밍의 벗 PivotOJ
PivotOJ

Friends

시간 제한: 2000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — katt1BOJ 21333

문제

NN friends are playing a game. The game is played on a row of LL squares, numbered from 00 to L1L - 1, where squares ii and i+1i+1 are adjacent to each other. At most one friend stand on each square at any given time. In each step of the game, one friend jumps from its current square to a new (non-occupied) square.

In any moment of the game, the score of a friend is the length of the longest contiguous segment of friends it is part of. This means that if a friend stands on some position xx, and there are friends on positions a,a+1,...,x1,x,x+1,...,b1,ba, a + 1, ..., x - 1, x, x + 1, ..., b - 1, b, the score of the friend is ba+1b - a + 1.

The total score of the game is the sum of scores for all friends. At various times during the game, the friends wonder what their current total score is.

입력

The sample judge reads input in the following format:

  • line 11: N L Q
  • line 22: P[0] P[1] .. P[N - 1]
  • lines 33 to 3+Q13 + Q - 1: each line represents either a jump or a score question. If the line is 0 A B, a jump from AA to BB is to be made, and if the line is 1 a scoring question is to be made.

출력

For each scoring question, the judge writes a line with the return value of score().

예제

예제 1

입력
3 7 5
1 3 4
1
0 4 2
1
0 3 0
1
출력
5
9
9
코드를 제출하려면 로그인하세요.