Skip to content

Commit

Permalink
16차시 업로드
Browse files Browse the repository at this point in the history
  • Loading branch information
YIM2UL2ET committed Apr 11, 2024
1 parent 7986fda commit 2146ac6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
| 13차시 | 2024.04.01 | BFS | [BOJ 7569](https://www.acmicpc.net/problem/7569) | [BOJ 7569 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/42) |
| 14차시 | 2024.04.04 | 우선순위 큐 | [BOJ 11286](https://www.acmicpc.net/problem/11286) | [BOJ 11286 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/43) |
| 15차시 | 2024.04.09 | 구현 | [BOJ 14719](https://www.acmicpc.net/problem/14719) | [BOJ 14719 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/48) |
| 16차시 | 2024.04.09 | 구현 | [BOJ 15927](https://www.acmicpc.net/problem/15927) | [BOJ 15927 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/51) |
---
22 changes: 22 additions & 0 deletions YIM2UL2ET/애드 혹/16차시 - BOJ 15927.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <algorithm>

bool isOneChar(std::string str) {
int size = str.size();
for (int i = 1; i < size; i++) {
if (str[i-1] != str[i]) return false;
}
return true;
}

int main(void) {
std::string str, rstr;
std::cin >> str, rstr = str;
std::reverse(rstr.begin(), rstr.end());

if (isOneChar(str)) std::cout << -1;
else if (str == rstr) std::cout << str.size()-1;
else std::cout << str.size();

return 0;
}

0 comments on commit 2146ac6

Please sign in to comment.