백준 c++
[백준 10866번-C++] 덱
http://acmicpc.net/problem/10866 {코드} #include #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, tmp; deque dq; string op; cin >> n; while (n--) { cin >> op; if (op == "push_front") { cin >> tmp; dq.push_front(tmp); } else if (op == "push_back") { cin >> tmp; dq.push_back(tmp); } else if (op == "pop_front") { if (dq.empty()) cout
[백준 17609번-C++] 회문
http://acmicpc.net/problem/17609 {코드} #include #include using namespace std; string s; int isPalindrome(int left, int right, bool testPseudo) { while (left < right) { if (s[left] != s[right]) { if (testPseudo) { if (isPalindrome(left+1, right, false) == 0 || isPalindrome(left, right-1, false) == 0) return 1; } return 2; } left++; right--; } return 0; } int main() { ios_base::sync_with_stdio(fals..
[백준 9012번-C++] 괄호
http://acmicpc.net/problem/9012 {코드} #include #include #include using namespace std; int main() { int n; string s, ans = ""; stack st; cin >> n; while (n--) { cin >> s; stack st; for (const char &c : s) { if (c == '(') { st.push(c); } else { if (!st.empty()) { st.pop(); } else { st.push('('); break; } } } if (!st.empty()) { ans += "NO\n"; } else { ans += "YES\n"; } } cout