본문 바로가기
반응형

C++153

[알고리즘] 경사로 + 활주로 건설 포인트 가로 세로를 똑같은 함수를 이용하여 구한다. (사용되는 파라미터 배열 어떻게 들어가는지 볼 것) 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. c++/cpp #include #include #define endl "\n" #define MAX 100 using namespace std; int n, k; int map[MAX][MAX]; int map2[MAX][MAX]; bool canMakeRoad(int A[][MAX], int x, int y) { int cmp = A[x][y + 1]; for (int j = y + 1; j < y + 1 + k; j++) { if (A[x][j] != cmp) return false; } return true; } int make(int A[.. 2021. 3. 24.
[알고리즘] 이중우선순위큐 포인트 힙의 특성을 이용해보자 문제가 맞는지 틀린지는 잘 모르겠다. 이번, 문제는 일단 푼 정도 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. python import heapq def solution(operations: list) -> list: answer = [] for operations in operations: data = operations.split() if data[0] == 'I': heapq.heappush(answer, int(data[1])) elif answer and data[0] == 'D' and data[1] == '-1': heapq.heappop(answer) elif answer and data[0] == 'D' and data[1] == '1': ans.. 2021. 3. 19.
[알고리즘] 베스트 앨범 포인트 해시를 사용해서 적절히 정렬 기준을 만들고 실행할 수 있는가를 보여준다. 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. python from collections import defaultdict def solution(genres: list, plays: list) -> list: answer = [] hash = defaultdict(list) for genre, play, index in zip(genres, plays, range(len(plays))): hash[genre].append([play, index]) genreSort = sorted(list(hash.keys()), key=lambda x: sum(map(lambda y: y[0], hash[x])), revers.. 2021. 3. 19.
[알고리즘] 미세먼지 안녕! 포인트 구현을 잘 할 수 있는가? , 맵을 복사하고 다시 적용을 할 수 있어야 한다. 잘 밀 수 있는가? 긴장하지 말고 천천히 구하자. 결국은 구할 수 있는 문제이다. 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. #include #include using namespace std; int n, m, t; int map[51][51]; int cmap[51][51]; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; pair conditioner[2]; void expand() { memcpy(cmap, map, sizeof(map)); //map 복사 for (int x = 0; x < n; x++) { for (int y = 0; y < m; y+.. 2021. 3. 18.
반응형