Algorithm/BOJ
-
KOI 2017 고등부 2번 / 문명 - 14868Algorithm/BOJ 2020. 9. 12. 21:55
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 #include #include using namespace std; int N, K; vector arr; queue Q[2]; int xarr[4] = {0, 0, 1, -1}; int yarr[4] = {1, -1, 0..
-
KOI 2018 중등부 3번 / 물탱크 - 15972Algorithm/BOJ 2020. 9. 10. 17:36
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 #include #include #include..
-
KOI 2019 1차 고등부 2번 / 점프 - 17613Algorithm/BOJ 2020. 8. 30. 00:10
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 #include using namespace std; int arr[31]; int getIdx(int u) { int ret; for(ret = 0; ret u) return ret-1; } int cal(int n) { return 1+n*(n+1)/2; } int divide(int s, int e, int p) { if(!s && !e) return p; int idx; int ne = e; int ret = 0; while(true) { idx = getIdx(ne); if..
-
KOI 2019 1차 고등부 1번 / 쇼핑몰 - 17612Algorithm/BOJ 2020. 8. 24. 13:08
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 #include #include using namespace std; int N, K; struct Casher { int idx; int rest; }; struct Mem { int mnum; int otime; int cidx; }; bool operator stnum; Casher c = cpq.top(); cpq.pop(); c.rest -= stnum; m.otime = c.rest; m..
-
KOI 2019 1차 중등부 2번 / 직각다각형 - 17611Algorithm/BOJ 2020. 8. 24. 12:10
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 #include #include using namespace std; int N; struct Node { int idx; char label; }; bool operator> su >> sv; bu = su, bv = sv; for(int i = 0; i> u >> v; mkpq(u, bu, v, bv); bu = u, bv = v; } mkpq(u, s..
-
KOI 2019 1차 중등부 1번 / 양팔저울 - 17610Algorithm/BOJ 2020. 8. 13. 15:22
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 #include #include using namespace std; int N; int arr[13]; vector flag; int sum; void slv(int idx, int cs, int num) { if(idx == N) { if(num >= 1 && !flag[num]) { flag[num] = true; --sum; } return; } if(cs == 1) num += arr[idx]; else if(cs == 2) num -= arr[idx]; slv(idx+1, 0, num); slv(idx+..