Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 유니온 파인드
- c++
- 자료구조
- VR
- 문자열
- ue5
- 그리디 알고리즘
- 시뮬레이션
- 투 포인터
- BFS
- 누적 합
- 브루트포스
- 유니티
- 우선순위 큐
- DFS
- 백트래킹
- 정렬
- 백준
- 구현
- 알고리즘
- 트리
- 그래프
- 수학
- 다익스트라
- 재귀
- XR Interaction Toolkit
- 다이나믹 프로그래밍
- 스택
- Team Fortress 2
- Unreal Engine 5
Archives
- Today
- Total
1일1알
백준 1972번 놀라운 문자열 C++ 본문
https://www.acmicpc.net/problem/1972
1972번: 놀라운 문자열
대문자 알파벳으로만 이루어져 있는 문자열이 있다. 이 문자열에 대해서 ‘D-쌍’이라는 것을 정의할 수 있는데, 이 문자열에 포함되어 있는, 거리가 D인 두 문자를 순서대로 나열한 것을 이 문
www.acmicpc.net
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
string str;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
while (true) {
cin >> str;
if (str == "*") break;
bool surprise = true;
for (int i = 1; i < str.length(); i++) {
unordered_set<string> us;
for (int j = 0; j < str.length(); j++) {
if (j + i >= str.length()) break;
string tmp = "";
tmp += str[j];
tmp += str[j + i];
auto it = us.find(tmp);
if (it == us.end()) us.insert(tmp);
else surprise = false;
}
}
if (surprise) {
cout << str <<" is surprising.\n";
}
else {
cout << str << " is NOT surprising.\n";
}
}
}
'알고리즘' 카테고리의 다른 글
백준 11332번 시간초과 C++ (1) | 2023.02.28 |
---|---|
백준 14713번 앵무새 C++ (0) | 2023.02.27 |
백준 18513번 샘터 C++ (0) | 2023.02.24 |
백준18429번 근손실 C++ (0) | 2023.02.23 |
백준 11265번 끝나지 않는 파티 C++ (0) | 2023.02.22 |