Skip to content

Commit

Permalink
Merge pull request #51 from AlgoLeadMe/16-YIM2UL2ET
Browse files Browse the repository at this point in the history
16-YIM2UL2ET
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents 552dbe0 + 2146ac6 commit 2a1612d
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 2a1612d

Please sign in to comment.