- 난이도: 브론즈 1
- 알고리즘: 문자열
큐를 이용하여 풀어보았다.
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
int main() {
cin.tie(NULL);
cout.tie(NULL);
std::ios::sync_with_stdio(false);
string str;
deque<char> q;
cin >> str;
for (int i = 0; i < str.length(); i++) {
q.push_front(str[i]);
}
bool flag = false;
while (q.size() > 1) {
if (q.front() != q.back()) {
flag = true;
break;
}
else {
q.pop_front();
q.pop_back();
}
}
if (flag) cout << 0;
else cout << 1;
}