본문 바로가기

Coding Test

(163)
백준 1918 후위 표기식 https://www.acmicpc.net/problem/1918#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; string ans; cin >> s; stack st; for (int i = 0; i 1. 문제중위 표기식이 주어진다. 이 때 이와 동일한 후위 표기식을 출력하라. 단, 식은 알파벳 대문자만이 첫 문자로 주어지며, 알파벳 대문자와 +, -, *, /, (, )로만 이루어져 있다. 2. 풀이 주어진 대문자 외 수식 기호의 우선순위는 다음과 같다.(, )*, /+, -위 식을 보면 기호..
백준 19583 싸이버개강총회 https://www.acmicpc.net/problem/19583#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s, e, q; int ans = 0; map att; cin >> s >> e >> q; string t, nick; while (cin >> t >> nick) { if(att[nick]==1 && t >= e && t 1. 문제개강총회를 시작한 시간 S, 개강총회를 끝낸 시간 E, 개강총회 스트리밍을 끝낸 시간 Q가 주어진다. 이후 스트리밍 영상의 채팅 기록과 해당 ..
백준 1927 최소 힙 https://www.acmicpc.net/problem/1927#include #include using namespace std;priority_queue, greater> q;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 0; i > x; if (x == 0) { if (!q.empty()) { cout 1. 문제최소 힙에 대한 n개의 연산이 주어진다. 자연수가 들어갈 경우 배열에 그 값을 추가하고, 0이 입력될 경우 해당 배열의 최솟값을 출력 후 이를 제거한다. 연산의 결..
백준 5430 AC https://www.acmicpc.net/problem/5430#include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int test = 0; test dq; int n; cin >> func; cin >> n; cin >> sarr; string temp; for (int i = 0; i = 0; i--) { cout 1. 문제정수 배열에 연산을 하기 위한 ..
백준 5397 키로거 https://www.acmicpc.net/problem/5397#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int test = 0; test > s; stack st; for (int i = 0; i ') { if (!st.empty()) { ans.push_back(st.top()); st.pop(); } } ..
백준 22942 데이터 체커 https://www.acmicpc.net/problem/22942#include #include #include #include using namespace std;vector> arr;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 0; i > x >> r; arr.push_back(make_tuple(x - r, i, true)); arr.push_back(make_tuple(x + r, i, false)); } sort(arr.begin(), arr.end()); stack st; fo..
백준 2493 탑 https://www.acmicpc.net/problem/2493#include #include #include using namespace std;vector> arr;vector ans;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; arr.resize(n); ans.resize(n, 0); for (int i = 0; i > temp; arr[i] = make_pair(temp, i + 1); } stack> st; for (int i = 0; i 1. 문제높이가 서로 다른 탑의 개수 n과 각 탑의 높이가 주어진다. ..
백준 2504 괄호의 값 https://www.acmicpc.net/problem/2504#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; int ans = 0; cin >> s; stack st; int temp = 1; for (int i = 0; i 0 && s[i - 1] == '(') { ans += temp; temp /= 2; st.pop(); } else { ..