RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0680

Sliding Window Summation

Platinum V 플래티넘 V
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Bessie has a hidden binary string \(b_1b_2\dots b_N\) (\(1\le N\le 2\cdot 10^5\)).
The only information about \(b\) you are given is a binary string
\(r_1r_2\dots r_{N-K+1}\) (\(1 \le K \le N\)), where \(r_i\) is the remainder when
the number of ones in the length-\(K\) window of \(b\) with leftmost index \(i\) is
divided by two.

Output the minimum and maximum possible numbers of ones in Bessie's hidden
binary string.

Problem credits: Benjamin Qi

제약

SCORING

  • Input 2: \(N\le 8\)
  • Inputs 3-4: \(K\le 8\) and the sum of \(N\) over all tests does not exceed \(10^4\).
  • Inputs 5-11: No additional constraints.

Problem credits: Benjamin Qi

입력 형식

There are \(T\) (\(1\le T\le 10^3\)) independent test cases to be solved. Each test
is specified by the following:

The first line contains \(N\) and \(K\).

The second line contains the binary string \(r_1\dots r_{N-K+1}\), where
\(r_i=\sum_{j=i}^{j+K-1}b_j\pmod{2}\).

It is guaranteed that the sum of \(N\) over all tests does not exceed \(10^6\).

출력 형식

For each test case, output the minimum and maximum possible numbers of ones in
Bessie's hidden binary string, separated by a single space.

예제 1
입력
7
5 1
10011
5 2
1001
5 3
100
5 5
0
5 5
1
4 4
1
5 2
0000
출력
3 3
2 3
1 4
0 4
1 5
1 3
0 5
설명

For the first test case, \(K=1\) means that \(r=b\), and the number of ones in \(r\)
is \(3\).

For the second test case, there are two possibilities for \(b\): 10001 and 01110,
having \(2\) and \(3\) ones, respectively.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > First Contest > Silver

태그

평가 및 의견

Sliding Window Summation

개요
출제자 난이도 Platinum V 플래티넘 V 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Sliding Window Summation

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