Algorithm
-
Segment TreeAlgorithm/세그먼트, 펜윅트리 2020. 3. 13. 18:00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 //segment tree //배열의 구간 최소 쿼리를 해결하기 위한 구간 트리의 구현 struct RMQ { //배열의 길이 int n; //각 구간의 최소치 vector rangeMin; RMQ(const vector& arr) { n = arr.size(); rangeMin.resize(n*4); init(arr, 0, n-1, 1); } //n..
-
퀘스트 중인 모험가 - 15816Algorithm/BOJ 2020. 3. 13. 16:28
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 #include #include #include #include using namespace std; int N, M; int aidx; int arr[20000..
-
전화번호 목록 - 5052Algorithm/BOJ 2020. 3. 12. 19:56
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 //5052 - 전화번호 목록 #include #include #include using namespace std; int N; vector arr; void init() { cin >> N; arr = vector(N); for(int i = 0; i> arr[i]; sort(arr.begin(), arr.end()); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int C; cin >> C; for(int tn = ..
-
최종 순위 - 3665Algorithm/BOJ 2020. 3. 12. 19:27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 //3665 - 최종 순위 #include #include using namespace std; int N, M; int arr[501]; int idx[501]; int adj[501][501]; vector visit; void init() { cin >> N; for (int i = 1; i x >..
-
최소비용 구하기 2 - 11779Algorithm/BOJ 2020. 3. 12. 03:11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 //11779 - 최소비용 구하기2 #include #include #include #include using namespace std; #define INF 1000000000 int N, M; vector adj; int S, E; void init() { cin >> N >> M; adj = vector(N+1); int x, y..
-
열쇠 - 9328Algorithm/BOJ 2020. 3. 12. 02:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12..
-
백조의 호수 - 3197Algorithm/BOJ 2020. 3. 11. 05:37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 //3197 - 백조의 호수 #include #include #include..