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

11760번 - Mastering Mastermind 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB35016714449.827%

문제

Mastermind is a two-person code breaking game which works as follows. The first person (the code maker) creates a sequence of n colored pegs (with duplicate colors allowed) and hides it from view. This sequence of pegs is the code.

The second person (the code breaker) has the job of trying to determine the code maker’s code and she does so by making a series of guesses. Each guess also consists of n colored pegs. After each guess, the code maker gives the code breaker feedback about how close she is. This feedback consists of two number r and s, where

  • r = the number of pegs that are identical in both color and position in the code and the guess, and
  • s = the number of remaining pegs that are identical in color but not in the same position.

For example, if the code is BACC (where we use different letters to represent colors) and the guess is CABB, then r = 1 (the A in the second position of both the code and the guess) and s = 2 (a B and C in the remaining three characters). Note that only one of the B’s in the guess will “match” with the single B in the code: once pegs in the code and the guess have been “matched” with each other, they can’t be matched with any other pegs.

Your job in this problem is to determine r and s given a code and a guess

입력

The input is a single line containing a positive integer n ≤ 50 (the length of the code) followed by two strings of length n — the first of these is the code and the second is the guess. Both code and guess are made up of upper-case alphabetic characters.

출력

Output the values of r and s for the given input.

제한

예제 입력 1

4 BACC CABB

예제 출력 1

1 2

예제 입력 2

13 ABCDEFGHIJKLM NOPQRSTUVWXYZ

예제 출력 2

0 0

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2015 East Central Regional Contest 연습 세션 PB번

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

출처

대학교 대회

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

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