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

Cowreography

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

의견: 0

설명

The cows have formed a dance team, and Farmer John is their choreographer! The
team's latest and greatest dance involves \(N\) cows (\(2 \le N \le 10^6\)) standing
in a line. Each move in the dance involves two cows, up to \(K\) positions apart
(\(1 \le K < N\)), gracefully jumping and landing in each other's position.

There are two types of cows in the line – Guernseys and Holsteins. As such,
Farmer John has documented the dance as a sequence of length-\(N\) binary
strings
, where a \(0\) represents a Guernsey, a \(1\) represents a Holstein, and
the overall string represents how the cows are arranged in the line.

Unfortunately, Farmer Nhoj (who choreographs for a rival team) has sabotaged the
dance and erased all but the first and last binary strings! With a big
competition quickly approaching, Farmer John must waste no time in
reconstructing the dance.

Given these two binary strings, help Farmer John find the minimum number of
moves in the dance!

Problem credits: Benjamin Qi

제약

SCORING

  • Inputs 4-5: \(K=1\)
  • Inputs 6-7: Both strings have at most \(8\) ones.
  • Inputs 8-15: \(N\le 5000\)
  • Inputs 16-23: No additional constraints.

Problem credits: Benjamin Qi

입력 형식

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

The second line contains the first binary string.

The third line contains the last binary string.

It is guaranteed that both binary strings contain the same number of ones.

출력 형식

The minimum number of moves in the dance.

예제 1
입력
4 1
0111
1110
출력
3
설명

One possible dance:

0111 -> 1011 -> 1101 -> 1110
예제 2
입력
5 2
11000
00011
출력
3
설명

One possible dance:

11000 -> 01100 -> 00110 -> 00011
예제 3
입력
5 4
11000
00011
출력
2
설명

One possible dance:

11000 -> 10010 -> 00011
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > US Open > Gold

태그

평가 및 의견

Cowreography

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

Log in to rate problems.

개별 의견

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

풀이 제출

Cowreography

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