공부
-
[HackerRank/Basic Select] Weather Observation Station 4공부/PS ( SQL) 2022. 5. 15. 22:48
https://www.hackerrank.com/challenges/weather-observation-station-4/problem?isFullScreen=true Weather Observation Station 4 | HackerRank Find the number of duplicate CITY names in STATION. www.hackerrank.com 문제 풀이 SELECT COUNT(CITY) - COUNT(DISTINCT(CITY)) FROM STATION
-
[C++] STL - map, set공부/C, C++ 2022. 5. 12. 17:33
STL container - 시퀀스 컨테이너 / 연관 컨테이너 시퀀스 컨테이너: vector, list, deque 등 순서대로 데이터를 보관할때 사용 연관 컨테이너: map, set 등 형태로 데이터를 보관할때 사용. 찾고자하는 데이터를 빠르게 찾을 때 사용. map, set key의 중복을 허용하지 않음 중복되는 key를 사용하는 경우에는 컨테이너 앞에 'multi'를 붙임. ex) multi_map, multi_set key 기준으로 데이터를 정렬하여 저장함 map Red-Black tree 자료구조를 가짐 형태로 데이터를 저장 key를 기준으로 오름차순 정렬함 map 선언 예시) #include map map1; set map과 비슷하지만 map과 달리 key만 저장함 key를 기준으로 오름차순 ..
-
[BOJ] 19238 스타트 택시 / C++공부/PS (백준) 2022. 4. 28. 23:49
https://www.acmicpc.net/problem/19238 19238번: 스타트 택시 첫 줄에 N, M, 그리고 초기 연료의 양이 주어진다. (2 ≤ N ≤ 20, 1 ≤ M ≤ N2, 1 ≤ 초기 연료 ≤ 500,000) 연료는 무한히 많이 담을 수 있기 때문에, 초기 연료의 양을 넘어서 충전될 수도 있다. 다 www.acmicpc.net #include #include #include #include #define MAX_N 21 #define MAX_M 401 using namespace std; int N, M, fuel; int MAP[MAX_N][MAX_N]; // -2: EMPTY, -1: int dist[MAX_N][MAX_N]; struct DRIVER { int r, c, t;..
-
[BOJ] 23288 주사위 굴리기 2공부/PS (백준) 2022. 4. 24. 21:07
https://www.acmicpc.net/problem/23288 23288번: 주사위 굴리기 2 크기가 N×M인 지도가 존재한다. 지도의 오른쪽은 동쪽, 위쪽은 북쪽이다. 지도의 좌표는 (r, c)로 나타내며, r는 북쪽으로부터 떨어진 칸의 개수, c는 서쪽으로부터 떨어진 칸의 개수이다. 가장 왼 www.acmicpc.net #include #include #define MAX21 using namespace std; int N, M, K; int BOARD[MAX][MAX]; int visited[MAX][MAX]; int dr[] = { -1,0,1,0 }; // 북동남서 int dc[] = { 0,1,0,-1 }; struct DICE { int r, c, bottom, top, front, b..
-
[BOJ] 16235 나무 재테크공부/PS (백준) 2022. 4. 19. 23:39
https://www.acmicpc.net/problem/16235 16235번: 나무 재테크 부동산 투자로 억대의 돈을 번 상도는 최근 N×N 크기의 땅을 구매했다. 상도는 손쉬운 땅 관리를 위해 땅을 1×1 크기의 칸으로 나누어 놓았다. 각각의 칸은 (r, c)로 나타내며, r은 가장 위에서부터 www.acmicpc.net 비교적 쉬운 문제였지만 (문제 설명대로 구현만 하면 됐기에) 시간 제한이 0.3초로 매우 짧았기때문에 처음 제출한 코드는 시간초과가 떴다. #include #include #include using namespace std; int N, M, K; int A[20][20]; // 로봇이 공급하는 양분 int nutrient[20][20]; struct TREE { int age, ..
-
[BOJ] 16236 아기 상어 / C++공부/PS (백준) 2022. 4. 16. 02:52
https://www.acmicpc.net/problem/16236 16236번: 아기 상어 N×N 크기의 공간에 물고기 M마리와 아기 상어 1마리가 있다. 공간은 1×1 크기의 정사각형 칸으로 나누어져 있다. 한 칸에는 물고기가 최대 1마리 존재한다. 아기 상어와 물고기는 모두 크기를 가 www.acmicpc.net #include #include #include #include using namespace std; int N, M; int MAP[30][30]; // 0: 빈칸, 1 ~ 6: 물고기의 크기, 9: 아기 상어의 위치 int dist[30][30]; int answer = 0; int dr[] = { -1,0,1,0 }; int dc[] = { 0,-1,0,1 }; struct SHARK..
-