Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/26650
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
팬그램(pangram)이란 알파벳의 모든 문자가 최소 한 번씩 등장하는 문자열을 말한다. 팬그램의 예시로는 "The quick brown fox jumps over the lazy dog", "The five boxing wizards jump quickly"등이 있다. 팬그램은 그 자체로 충분히 아름다운 문자열이지만, 래오는 팬그램 중에서도 모든 알파벳이 순서대로 나열된 팬그램만이 아름답다고 생각해 이를 그램팬이라 부르기로 했다.
예를 들어 "ABBCDEFGGHIJKLMNOPQRSSTUVWXYZ"는 그램팬이며, "BABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCADEFGHIJKLMNOPQRSTUVWXYZ"은 팬그램이지만 그램팬은 아니다.
어느 날 북과고 컴퓨터실 구석에서 문자열
$S$ 를 발견한 래오는
$S$ 의 부분 문자열 중 그램팬인 것의 개수가 궁금해졌다. 래오를 위해 이를 계산하는 프로그램을 작성해보자.
문자열
$S$ 의 부분 문자열이란, 문자열의 연속된 일부를 의미한다. 부분 문자열 중 같은 것이 있더라도 기존 문자열에서의 위치가 다르다면 다른 것으로 센다.
🔍 풀이 방법
결국 한번 검사할때, A가 몇번 연속되는지, Z가 연속되는지만 확인하면 된다.
특정 문자열이 그램팬임을 확인하면, A 개수 * Z 개수 = 그 문자열에서 만들어질 수 있는 그램팬 갯수 임을 알면 끝!
⏳ 회고