Algorithm/baekjoon
-
(이진 검색 트리)7662 이중 우선순위 큐Algorithm/baekjoon 2022. 2. 25. 15:32
https://www.acmicpc.net/problem/7662 7662번: 이중 우선순위 큐 입력 데이터는 표준입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터의 첫째 줄에는 Q에 적 www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include using namespace std; multiset ms; int main() { cin.tie(NULL); cin.sync_with_stdio(false); cout.tie(NULL); int T; cin >> T; while (T--) ..
-
(dp)1463 1로 만들기/9095 1,2,3 더하기Algorithm/baekjoon 2022. 2. 22. 17:03
1.1463 1로 만들기 https://www.acmicpc.net/problem/1463 1463번: 1로 만들기 첫째 줄에 1보다 크거나 같고, 106보다 작거나 같은 정수 N이 주어진다. www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; int d[1000001]; int main() { cin.tie(NULL); cin.sync_with_stdio(false); cout.tie(NULL); int N; cin >> N; d[1] = 0; for (int i = 2; i T; for (int i = 0; i < T; i++) { int n; cin..
-
(bfs/dfs)4963 섬의 개수Algorithm/baekjoon 2022. 2. 22. 15:51
bfs/dfs 연장선상의 문제였지만 푸는 데 시간이 오래걸렸다. 고난이 많았던 문제... https://www.acmicpc.net/problem/4963 4963번: 섬의 개수 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스의 첫째 줄에는 지도의 너비 w와 높이 h가 주어진다. w와 h는 50보다 작거나 같은 양의 정수이다. 둘째 줄부터 h개 줄에는 지도 www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #define X first #define Y second using namespace std; int dx[8] = { -1,-1,-1,0,1,1,1,0 }; int..
-
1260 DFS와 BFS/11724 연결요소의 개수Algorithm/baekjoon 2022. 2. 20. 18:55
(1)DFS와 BFS https://www.acmicpc.net/problem/1260 1260번: DFS와 BFS 첫째 줄에 정점의 개수 N(1 ≤ N ≤ 1,000), 간선의 개수 M(1 ≤ M ≤ 10,000), 탐색을 시작할 정점의 번호 V가 주어진다. 다음 M개의 줄에는 간선이 연결하는 두 정점의 번호가 주어진다. 어떤 두 정점 사 www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; vector graph[1001]; vector visited(1001, false); void DFS(int ver) { cout > v1 >> v2; graph[..
-
(재귀)1629 곱셈/1074 ZAlgorithm/baekjoon 2022. 2. 19. 12:10
1.1629 곱셈 https://www.acmicpc.net/problem/1629 1629번: 곱셈 첫째 줄에 A, B, C가 빈 칸을 사이에 두고 순서대로 주어진다. A, B, C는 모두 2,147,483,647 이하의 자연수이다. www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include using namespace std; using ll = long long; ll POW(ll a, ll b, ll c) { if (b == 1) return a % c; ll value = POW(a, b / 2, c); value = value * value % c; if (b % 2 == 0) return value; ..
-
1978 소수 찾기/2609 최대공약수와 최소공배수Algorithm/baekjoon 2022. 2. 19. 00:05
1.1978 소수 찾기 https://www.acmicpc.net/problem/1978 1978번: 소수 찾기 첫 줄에 수의 개수 N이 주어진다. N은 100이하이다. 다음으로 N개의 수가 주어지는데 수는 1,000 이하의 자연수이다. www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); cout.tie(NULL); int n; cin >> n; int cnt = 0; for (int i = 0; i > a; bool flag =..
-
1181 단어 정렬/11650 좌표 정렬하기/11651 좌표 정렬하기2/2750 수 정렬하기/10989 수 정렬하기3/10814 나이순 정렬Algorithm/baekjoon 2022. 2. 18. 22:42
1. 1181 단어 정렬 https://www.acmicpc.net/problem/1181 1181번: 단어 정렬 첫째 줄에 단어의 개수 N이 주어진다. (1 ≤ N ≤ 20,000) 둘째 줄부터 N개의 줄에 걸쳐 알파벳 소문자로 이루어진 단어가 한 줄에 하나씩 주어진다. 주어지는 문자열의 길이는 50을 넘지 않는다. www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int n; cin >> n; string* arr = new string[n]; for (int i =..
-
1032 명령 프롬프트/1085 직사각형에서 탈출/1259 팰린드롬수/15829 HashingAlgorithm/baekjoon 2022. 2. 14. 11:26
1. 1032 명령 프롬프트 https://www.acmicpc.net/problem/1032 #include #include using namespace std; char arr[5][15]; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int forn; cin >> forn; string *orders=new string [forn]; for (int i = 0; i > str1; orders[i] = str1; } string output=""; for (int j = 0; j < orders[0].size(); j++) { char a; bool flag = true; for (int..