Algorithm
-
두 로봇 - 15971Algorithm/BOJ 2020. 3. 15. 21:51
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 //15971 - 두 로봇 #include #include #include using namespace std; #define INF 1000000000 int N, S, E; vector adj; void init() { cin >> N >> S >> E; adj = vector(N+1); int x, y, r; for(int i = 0; i> x ..
-
*빛*영*우* - 15807Algorithm/BOJ 2020. 3. 15. 20:53
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 //15807 - *빛*영*우* //dp로 해결 #include using namespace std; int N, M; int arr[3001][3001]; int cache[3001][3001]; int dp(int x, int y) { if (x 3000 || y 3000) return 0; return cache[x][y]; } int A(int x, int y) { int ret = 0; if (..
-
구간 합 구하기 - 2042Algorithm/BOJ 2020. 3. 15. 05:49
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 //2042 - 구간 합 구하기 #include #include using namespace std; int N, M, K; long long arr[1000001]; struct SegmentTree { int n; vector tree; SegmentTree(int n) : n(n),..
-
영우의 기숙사 청소 - 15806Algorithm/BOJ 2020. 3. 15. 04:19
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 //15806 - 영우의 기숙사 청소 #include #include using namespace std; int N, M, K, T; bool arr[2][301][301]; int xarr[8] = {-2, -2, -1, -1, 1, 1, 2, 2}; int yarr[8] = {-1, 1, -2, 2, -2, 2, -1, 1}; queue xQ[2]; queue yQ[2]; void init()..
-
내려가기 - 2096Algorithm/BOJ 2020. 3. 14. 03:35
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 //2096 - 내려가기 #include using namespace std; #define INF 100000000 int N; int arr[100000][3]; int cache[2][3]; int cache2[2][3]; void init() { cin >> N; for (int i = 0; i arr[i][j]; } int dp(int x, int y) { if (y ..
-
최솟값 - 10868Algorithm/BOJ 2020. 3. 13. 20: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 //10868 - 최솟값 #include #include using namespace std; #define INF 1000000001 int N, M; int arr[100001]; struct SegmentTree { int n; vector tree; SegmentTree(int n) : n(n), tree(n*4+1) { init(1, n, 1); } int init(int left, int right, i..
-
최솟값과 최댓값 - 2357Algorithm/BOJ 2020. 3. 13. 20:16
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 //2357 - 최솟값과 최댓값 #include #include using namespace std; #define INF 1000000001 int N, M; int arr[100001]; struct SegmentTree { int n; vector mintree; vect..