QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20960. 미친 과학자

Statistics

Farmer John의 사촌 Ben은 미친 과학자이다. 보통 가족 모임에서 마찰을 일으키지만, Farmer John이 소들에 관한 특별하고 색다른 문제를 만나면 도움이 될 때도 있다.

지금 Farmer John은 그런 문제를 만났다. 최근 Holstein과 Guernsey 두 품종의 소 $N$마리 ($1 \leq N \leq 1000$)를 주문했다. 주문은 $H$ (Holstein) 또는 $G$ (Guernsey)로 된 $N$개 문자 문자열로 지정했다. 하지만 소들이 농장에 도착해 줄을 세우니 원래와 다른 품종 문자열이 되었다.

두 문자열을 $A$, $B$라고 하자. $A$는 원래 원하던 품종 문자열, $B$는 도착할 때의 문자열이다. $B$의 소들을 재배열하여 $A$로 만들 수 있는지만 확인하는 대신, Farmer John은 Ben의 과학적 재치로 해결해 달라고 한다.

몇 달 후 Ben은 놀라운 기계 multi-cow-breed-flipinator 3000을 만든다. 임의의 연속된 소들의 부분 문자열에서 모든 $H$를 $G$로, 모든 $G$를 $H$로 바꾼다. Farmer John은 현재 순서 $B$를 원하던 순서 $A$로 바꾸는 최소 사용 횟수를 알고 싶다. 하지만 Ben의 능력은 기발한 장치를 만드는 데 그치므로 이 계산 문제를 해결해 주어야 한다.

입력

입력 첫째 줄에는 $N$이, 다음 두 줄에는 문자열 $A$, $B$가 주어진다. 각 문자열은 $H$ 또는 $G$인 $N$개 문자로 이루어진다.

출력

$B$를 $A$로 만드는 기계의 최소 사용 횟수를 출력하라.

예제

입력 1

7
GHHHGHH
HHGGGHH

출력 1

2

참고

먼저 FJ는 첫 번째 문자만의 부분 문자열을 바꿔 $B$를 GHGGGHH로 만들 수 있다. 다음으로 세 번째와 네 번째 문자 부분 문자열을 바꾸면 $A$가 된다. 두 번 사용하는 다른 조합들도 가능하다.

문제 출제: Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.