전체 글 88

[BAEKJOON] 1316 - 그룹 단어 체커

https://www.acmicpc.net/problem/1316 한 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우 그룹 단어라고 한다. 입력 받은 스트링에 각 문자가 유효한 지 체크하기 위해 이전에 체크한 문자와 현재 인덱스의 문자를 비교하고, 틀릴 경우 checker string에 해당 문자를 삽입한다. 만약 이전 문자와 현재 문자가 틀린데 checker string에 해당 문자가 있다면, 체크 중인 단어는 그룹 단어가 아니므로 count에서 제외 한다. #include #include #include #include int main() { std::ios::sync_with_stdio(false); int testCase = 0, result = 0; std::cin >> ..

[BAEKJOON] 1157 - 단어 공부

https://www.acmicpc.net/problem/1157 문자열을 입력 받은 후, 해당 문자열에 가장 많이 포함된 alphabet을 구하는 문제다. map에 각 alphabet별 개수를 저장 해 두고, 개수를 기준으로 오름차순으로 정렬하여 0번째, 1번째 item이 같은 개수를 가지면 ?를 출력하고, 아닐 경우 0번째 item을 출력하도록 구현하였다. #include #include #include #include #include // pair의 second value를 기준으로 sort하는 template 구조체 선언 template struct compare_pair_second { template bool operator() (const std::pair &left, const std::p..

[BAEKJOON] 2675 - 문자열 반복

https://www.acmicpc.net/problem/2675 이 문제는 특정 문자열 S의 item을 반복 횟수 R만큼 반복해서 출력하는 간단한 문제이다. #include #include int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); int testCase = 0, R = 0; std::string S; std::cin >> testCase; while(testCase--) { std::cin >> R >> S; int sLen = static_cast(S.length()); for(int idx = 0; idx < sLen; idx++) { for(int r = 0; r < R; ..