์ธ๋ฑ์Šค ํŠธ๋ฆฌ
Coding Test 2022. 10. 3. 00:10

2042๋ฒˆ: ๊ตฌ๊ฐ„ ํ•ฉ ๊ตฌํ•˜๊ธฐ (acmicpc.net) 2042๋ฒˆ: ๊ตฌ๊ฐ„ ํ•ฉ ๊ตฌํ•˜๊ธฐ ์ฒซ์งธ ์ค„์— ์ˆ˜์˜ ๊ฐœ์ˆ˜ N(1 ≤ N ≤ 1,000,000)๊ณผ M(1 ≤ M ≤ 10,000), K(1 ≤ K ≤ 10,000) ๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. M์€ ์ˆ˜์˜ ๋ณ€๊ฒฝ์ด ์ผ์–ด๋‚˜๋Š” ํšŸ์ˆ˜์ด๊ณ , K๋Š” ๊ตฌ๊ฐ„์˜ ํ•ฉ์„ ๊ตฌํ•˜๋Š” ํšŸ์ˆ˜์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N+1๋ฒˆ์งธ ์ค„ www.acmicpc.net #if 01 #include #include using namespace std; long long arr[1000001], tree[1000001]; int n, m, k;// ๋ฐ์ดํ„ฐ ๊ฐฏ์ˆ˜, ๋ณ€๊ฒฝ ํšŸ์ˆ˜, ๊ตฌ๊ฐ„ํ•ฉ ๊ณ„์‚ฐ ํšŸ์ˆ˜ // i๋ฒˆ์งธ ์ˆ˜๊นŒ์ง€์˜ ๋ˆ„์  ํ•ฉ์„ ๊ณ„์‚ฐํ•˜๋Š” ํ•จ์ˆ˜ // 0์ด ์•„๋‹Œ ๋งˆ์ง€๋ง‰ ๋น„ํŠธ๋งŒํผ ๋นผ๋ฉด์„œ ๊ตฌ๊ฐ„๋“ค์˜ ๊ฐ’์˜ ํ•ฉ ๊ณ„์‚ฐ long long p..

์ด์ง„ํƒ์ƒ‰
Coding Test 2022. 10. 3. 00:09

int BSearch(int arr[], int target) { int low = 0; int high = arr.length - 1; int mid; while(low target) high = mid - 1; else low = mid + 1; } return -1; }

compare struct์™€ function ์ฐจ์ด
Coding Test 2022. 9. 29. 14:47

// pq์— ์˜ฌ๋ฆผ์ฐจ์ˆœ์œผ๋กœ ๋„ฃ๊ณ  ์‹ถ์„ ๋•Œ struct cmp { bool operator() (Line a, Line b) { return a.e > b.e; } }; priority_queue pq; // ๋ฒกํ„ฐ๋ฅผ ์˜ฌ๋ฆผ์ฐจ์ˆœ์œผ๋กœ sortํ•˜๊ณ  ์‹ถ์„ ๋•Œ bool compare(Line a, Line b) { return a.s < b.s; } sort(monster.begin(), monster.end(), compare); priority queue ์— ๋“ค์–ด๊ฐˆ cmp bool struct

BOJ1944_๋ณต์ œ ๋กœ๋ด‡
Coding Test 2022. 9. 27. 07:47

#include #include #include using namespace std; struct Edge { int cost; int a; int b; }; bool cmp (Edge a, Edge b) { if(a.cost >= b.cost) return false; else return true; } int N, M; int parent[1001]; vector edges; int result; int getParent(int a) { if (parent[a] == a) return a; return parent[a] = getParent(parent[a]); } void unionParent(int a, int b) { a = getParent(a); b = getParent(b); if(a < ..

BOJ1922_๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ(ํฌ๋ฃจ์Šค์นผ, C++)
Coding Test 2022. 9. 27. 06:44

#include #include #include using namespace std; struct Edge { int cost; int a; int b; }; bool cmp (Edge a, Edge b) { if(a.cost >= b.cost) return false; else return true; } int N, M; int parent[1001]; vector edges; int result; int getParent(int a) { if (parent[a] == a) return a; return parent[a] = getParent(parent[a]); } void unionParent(int a, int b) { a = getParent(a); b = getParent(b); if(a < ..

BOJ2665_๋ฏธ๋กœ๋งŒ๋“ค๊ธฐ
Coding Test 2022. 9. 23. 17:18

#include #include #include #include #define INF (int(1e9)) using namespace std; struct Edge { int pos[2]; int cost; }; struct cmp { bool operator() (Edge a, Edge b) { if (a.cost d[cur.pos[0]][cur.pos[1]]) continue; for(int i = 0; i = N || nc >= N) continue; if (d[nr][nc] > N; memset(map, 0, sizeof(map)); string temp;..