티스토리 뷰
백준 1316번
문제 사이트 :
https://www.acmicpc.net/problem/1316
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define Max 26
int main(void) {
int Testcase;
int number = 0;
scanf("%d", &Testcase);
for (int t = 0; t < Testcase; t++) {
bool check = true;
bool Array[Max] = { false, };
char ch[101];
char last_ch = '\0';
scanf("%s", ch);
for (int i = 0; ch[i] != '\0'; i++) {
if (i == 0) { //제일 처음 문자
last_ch = ch[i];
Array[ch[i] - 'a'] = true;
}
else {
if (last_ch == ch[i]) { //전과 같은 문자이므로 패쓰
}
else {//전과 같은 문자가 아님
if (Array[ch[i] - 'a']) { //이전에 나왔던 문자임
check = false;
}
else {
last_ch = ch[i];
Array[ch[i] - 'a'] = true;
}
}
}
if (!check) {
break;
}
}
if (check) {
number++;
}
}
printf("%d", number);
return 0;
}
'PS > 백준' 카테고리의 다른 글
| 2577번 숫자의 개수 (0) | 2019.06.22 |
|---|---|
| 2448번 별 찍기 - 11 (0) | 2019.06.22 |
| 1157번 단어 공부 (0) | 2019.06.22 |
| 1152번 단어의 개수 (0) | 2019.06.22 |
| 1110번 더하기 사이클 (0) | 2019.06.22 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- UIView
- Swift
- Firebase
- 디자인패턴
- 부스트코스
- HumanInterfaceGuidelines
- Human Interface Guidelines
- Human Interface Guideline
- 알고리즘
- apple
- 싱글톤
- MVC
- 온라인저지
- DP
- 분할정복
- ios
- storage
- 오토레이아웃
- HIG
- 백준
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 |
| 30 |
글 보관함
