목록Problem Solving (49)
프로그래밍 공부
https://www.acmicpc.net/problem/2504 문제 해결 아이디어주어진 예시인(()[[]])([])로 봤을때2 * (2 + 3 * 3) + (2 * 3)인데이것을 풀어 쓰면(2 * 2) + (2 * 3 * 3) + (2 * 3) 이다이 아이디어를 바탕으로 스택을 활용해 문제를 해결 할 수 있다. 코드#include #include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); string str; stack s; int tmp = 1, ans = 0, len; cin >> str; len = str.length(); for(int i = 0; i ..
https://www.acmicpc.net/problem/17952 문제 자체는 직관적이다고 생각했고 어떻게 처리를 해야할지 생각하는 것이 중요하다 생각했다.특히, 문제를 받는 즉시 시작 이 부분이 중요했다는 생각이 들었다. 그 다음 문제는 예외 처리인데 스택이 비어있을때 조회를 하지 않는 코드를 처음에는 작성하지 않았었는데시작부터 0을 넣는 테스트 케이스가 있었던거 같아서 스택이 비어있을때는 스택에서 데이터를 조회하지 않게 처리를 해줘야했었다.#include #include using namespace std;#define SCORE first#define TIME secondint main(){ ios::sync_with_stdio(0); cin.tie(0); int n, ans = ..
https://www.acmicpc.net/problem/25497 조건을 잘못이해해서 빙빙 둘러갔다.L-R 이나 S-K 사이에 L 또는 S가 들어가서 LSRK 이런식으로도 되는 거였는데 잘못 이해해서예를 들어 R앞에 S가 나오면 break를 거는 방식으로 처음에 코딩을 했어서 삽질을 좀 했다.#include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; string str; int ans = 0; stack lr, sk; cin >> n; cin >> str; for(int i = 0; i
#include #include #include using namespace std;#define ll long long#define height first#define count second int main(){ ios::sync_with_stdio(0); cin.tie(0); stack> s; ll ans = 0; int n; cin >> n; vector h(n); for(int i = 0; i > h[i]; } for(int i = 0; i
#define _CRT_SECURE_NO_WARNINGS #include using namespace std; int arr[10][10]; int main() { int t; cin >> t; for (int i = 0; i > arr[j][k]; } } for (int j = 0; j < 9; j++) { if (!ans) break; int col_check[10]; fill(col_check, col_check + 10, 0); for (int k = 0; k < 9; k++) { col_check[arr[j][k]]++; if (..