본문 바로가기

Problem/ETC

[C/C++] BOJ 2493 :: 탑 BOJ 2493 :: 탑 문제 링크 : https://www.acmicpc.net/problem/2493 나의 풀이 머릿속으로 생각해서 풀었는데 바로 맞춰서 놀랐다.. 나의 스마트함에 감..탄.. ㅈㅅ * 탑은 왼쪽의 자신보다 높은 탑으로부터 영향을 받는다. 하나씩 탐색하면서 stack에 push한다. ex) 6 9 5 7 4 에서 6은 0stack : 6 9는 6보다 크므로 stack을 뒤져 이전에 탐색했던 탑의 높이와 비교한다.이 때, stack에 있던 값을 빼내며 탐색한다. => 다시 넣을 필요가 없다. ex) 7 6 5 4 3 2 6 일 때, 가장 끝 6은 두 번째 6을 만날 때까지 stack에서 pop한다. 그 후, ans를 갱신하고 두 번째 6을 pop하면 stack에는 7만 남게되고다시 자신..
[C/C++] BOJ 1158 :: 조세퍼스 문제 BOJ 1158 :: 조세퍼스 문제 문제 링크 : https://www.acmicpc.net/problem/1158 살짝 실수를 했지만..,, 간만에 C로 Linked List 구현해보기 ㅇㅅㅇ 나의 코드 Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/BOJ_1158/BOJ_1158.cpp 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273// 백준알고리즘 1158번 :: 조세퍼스 문제#includeusing n..
[SW Expert Academy] 1216. 회문2 [SW Expert Academy] 1216. 회문2 문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14Rq5aABUCFAYi&categoryId=AV14Rq5aABUCFAYi&categoryType=CODE 나의 코드 Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/SW_Expert_Academy_1216/SW_Expert_Academy_1216.cpp 12345678910111213141516171819202122232425262728293031323334353637383940414243..
[SW Expert Academy] 1215. 회문1 [SW Expert Academy]1215. 회문1 문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14QpAaAAwCFAYi 나의 코드 Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/SW_Expert_Academy_1215/SW_Expert_Academy_1215.cpp 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758// SW Expert Acad..
[C/C++] BOJ 5525 :: IOIOI BOJ 5525 :: IOIOI 문제 링크 : https://www.acmicpc.net/problem/5525 나의 풀이 KMP 방식으로 일치하는 단어가 있는지 탐색한 후, 있으면 값을 증가시킨다. KMP에 대한 설명 : https://j2wooooo.tistory.com/119?category=1038656 나의 코드 Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/BOJ_5525/BOJ_5525.cpp 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606..
[SW Expert Academy] 1213. String [SW Expert Academy] 1213. String 문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14P0c6AAUCFAYi&categoryId=AV14P0c6AAUCFAYi&categoryType=CODE 나의 풀이 String에서 특정 단어를 찾는 알고리즘은 아래와 같이 분류할 수 있다. 1. 고지식한 검색2. 라빈카프3. KMP4. 보이어-무어 나는 라빈카프 방식과 KMP 방식으로 풀어보았다. 라빈카프 : 찾을 단어의 HASH 값을 이용하여 동일한 HASH 값을 갖는 단어를 찾는다. O(N) KMP : 찾을 단어의 접두사와 접미사가 동일한 길이를 저장한 벡터를 이용하여, 탐색 ..
[C/C++] BOJ 2163 :: 초콜릿 자르기 BOJ 2163 :: 초콜릿 자르기 문제 링크 : https://www.acmicpc.net/problem/2163 규칙이 매우 간단하여 O(N)이 아닌 O(1)로 풀 수 있는 문제! 나의 코드 Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/BOJ_2163/BOJ_2163.cpp 12345678910111213// 백준알고리즘 2163번 :: 초콜릿 자르기 #includeusing namespace std; int N, M, ans;int main(void){ cin >> N >> M; ans = N*M - 1; cout
[C/C++] BOJ 1725 :: 히스토그램 BOJ 1725 :: 히스토그램 문제 링크 : https://www.acmicpc.net/problem/1725 모르겠어서 다른 분들이 푼 것을 참고하여 풀었다..!... 우선 규칙을 찾아내는 것이 중요한데 나는 규칙을 정말 못찾겠어가지고 ㅠ 못풀었다.. 핵심적인 규칙이 되는!! 구해야할 직사각형이 결정되는 순간은 이전의 막대높이보다 현재의 막대높이가 더 낮을 때이다. stack을 이용하여 O(N) 으로 풀 수 있다! 풀이 과정 나의 코드 Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/BOJ_1725/BOJ_1725.cpp 123456789101112131415161718192021222324252627..