Algorithm/BOJ
-
트리 나라 관광 가이드 - 15805Algorithm/BOJ 2020. 3. 16. 03:01
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 //15805 - 트리 나라 관광 가이드 #include using namespace std; int N; int arr[200000], parent[200000]; bool visit[200000]; int main() { cin >> N; for(int i = 0; i> arr[i], visit[i] = false; int ans = 0; int child = -1; for(int i = 0; i
-
저거 못 타면 지각이야!! - 15804Algorithm/BOJ 2020. 3. 16. 02:57
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 //15804 - 저거 못 타면 지각이야!! #include #include using namespace std; int N, K; int arr[100]; int wait[100]; void init() { cin >> N >> K; for(int i = 0; i> arr[i] >> wait[i]; } int main() { init(); int time = 1; int idx = 0; in..
-
주말 여행 계획 - 15808Algorithm/BOJ 2020. 3. 16. 02:54
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 //15808 - 주말 여행 계획 #include #include #include using namespace std; #define INF 1000000000 int N; vector adj; void init() { cin >> N; adj = vector(N+2); int c; for(int i = 1; i c; if(..
-
두 로봇 - 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()..