
풀이
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
vector<string> arr = {"c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="};
string s;
cin >> s;
for (int i = 0; i < arr.size(); i++) {
while (true)
{
int idx = s.find(arr[i]);
if (idx == -1) break;
else {
s.replace(idx, arr[i].length(), "!");
}
}
}
cout << s.length();
return 0;
}
배열을 선언하여 크로아티아 알파벳을 저장하고 입력값으로 주어진 문자열을 순회하면서 크로아티아 알파벳을 다른 문자로 변환하여 문자열의 총 길이를 구하는 방식으로 해결하였다.
string의 `find()`, `replace()`를 사용할 줄 알면 그렇게 어렵지 않은 문제였다.
'Memo > PS' 카테고리의 다른 글
| [백준] 1021 회전하는 큐 (0) | 2026.01.07 |
|---|---|
| [백준] 1316 그룹 단어 체커 (0) | 2026.01.01 |
| [백준] 1406 에디터 (0) | 2025.12.23 |
| [백준] 1919 애너그램 만들기 (0) | 2025.12.21 |
| [백준] 11328 Strfry (0) | 2025.12.19 |