Coding Test (163) 썸네일형 리스트형 백준 1967 트리의 지름 (C++) https://www.acmicpc.net/problem/1967#include #include #include #include using namespace std;vector> g[10001];int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; int ans = 0; cin >> n; for (int i = 0; i > u >> v >> d; g[u].push_back(make_pair(v, d)); g[v].push_back(make_pair(u, d)); } vector leaf; for (int i = 1; i q; .. 백준 2573 빙산 (C++) https://www.acmicpc.net/problem/2573 #include #include #include using namespace std;int dy[4] = {-1, 1, 0, 0};int dx[4] = {0, 0, -1, 1};vector> arr;bool visit[301][301];int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; int ans = 0; cin >> n >> m; arr.resize(n, vector(m)); for (int i = 0; i > arr[i][j]; } } while (true) { .. 백준 2812 크게 만들기 (C++) https://www.acmicpc.net/problem/2812 #include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; string num; vector ans; cin >> n >> k; cin >> num; int cnt = 0; stack s; for (int i = 0; i s.top()) { cnt++; s.pop(); } s.push(num[i]); } while (cnt = 0; i.. 백준 14502 연구소 (C++) https://www.acmicpc.net/problem/14502#include #include #include using namespace std;int dy[4] = {-1, 1, 0, 0};int dx[4] = {0, 0, -1, 1};int arr[8][8];int sim[8][8];bool visit[8][8];int n, m;int ans = 0;vector> virus;void initSim(){ for (int i = 0; i > n >> m; for (int i = 0; i > arr[i][j]; sim[i][j] = arr[i][j]; if (arr[i][j] == 2) { virus.push_back(mak.. 백준 2668 숫자고르기 (C++) https://www.acmicpc.net/problem/2668#include #include #include using namespace std;vector arr;bool visit[101];vector ans;void dfs(int cur, int s){ if (visit[cur]) { if (s == cur) { ans.push_back(cur); } return; } visit[cur] = true; dfs(arr[cur], s);}int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n;.. Leetcode 624 Maximum Distance in Arrays (C++) https://leetcode.com/problems/maximum-distance-in-arrays/ class Solution {public: int maxDistance(vector>& arrays) { int ans=0; int M=arrays[0].back(); int m=arrays[0].front(); for(int i=1;i1. 문제임의 개수의 정수 배열이 오름차순 정렬된 상태로 주어진다. 두 정수 a, b 사이의 거리를 abs(a, b)로 정의할 때, 서로 다른 배열의 두 정수의 최대 거리를 구하라.2. 풀이거리가 최대가 되려면 한 배열의 최댓값에서 다른 배열의 최솟값을 빼야 한다. 이를 이용하여 풀어보자. .. 백준 2696 중앙값 구하기 (C++) https://www.acmicpc.net/problem/2696#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 > n; vector ans; priority_queue, greater> pq; for (int i = 1; i > temp; pq.push(temp); vector arr; if (i % 2 == 1) { .. 백준 1711 직각삼각형 (C++) https://www.acmicpc.net/problem/1711#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; arr.resize(n); for (auto &item: arr) { cin >> item.first >> item.second; } int ans = 0; for (int i = 0; i = ik && ij >= jk) { if (ij == ik + jk) { .. 이전 1 ··· 4 5 6 7 8 9 10 ··· 21 다음