Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- moreeffectiveC++
- 프로그래머스
- 정렬알고리즘
- stl
- 델리게이트
- 크리티컬섹션
- UE4 커스텀로그
- 언리얼가비지컬렉터
- 약참조
- 람다사용정렬
- map
- 정렬
- dataasset
- 스마트포인터
- 자료구조
- C++최적화
- 강참조
- 데이터애셋
- 알고리즘
- BFS
- 선택정렬
- UML관련
- 애셋로드
- UELOG
- enumasByue
- 람다
- 언리얼엔진구조체
- C++
- UE_LOG
- unorder_map
Archives
- Today
- Total
기억을 위한 기록들
[백준 1316: 그룹 단어 체커] - C++ 본문
1316번: 그룹 단어 체커
그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때
www.acmicpc.net
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
string input;
vector<char> checkWord;
int result = 0;
for (int i = 0; i < n; i++)
{
checkWord.clear();
cin >> input;
bool isGroub = true;
int size = input.size();
for (int j = 0; j < size; j++)
{
if (find(checkWord.begin(), checkWord.end(), input[j]) != checkWord.end()) //이미 나온 문자인데
{
if (checkWord.back() != input[j]) //이미 사용한 문자의 맨뒤에도 없다면 멀리 떨어져있는 상태
{
isGroub = false; //그러므로 그룹단어 불가능
break;
}
}
else
{
char cur = input[j];
checkWord.push_back(cur);
}
}
if (isGroub)
{
result++;
}
}
cout << result << '\n';
return 0;
}
'Coding Test - cpp > String' 카테고리의 다른 글
[프로그래머스 lv 2 ] - 오픈채팅방 (0) | 2021.09.08 |
---|---|
[HackerRank/C++] Repeated String (0) | 2021.07.25 |
[백준 11721: 열 개씩 끊어 출력하기] - C++ (0) | 2021.03.25 |
[백준 11718: 그대로 출력하기] - C++ (0) | 2021.03.05 |
[백준 9012: 괄호] - C++ (0) | 2021.02.19 |