Skip to content

Commit 0031f5a

Browse files
committed
Quartz sync: Jun 10, 2025, 6:15 PM
1 parent 3e3d7ef commit 0031f5a

File tree

8 files changed

+267
-5
lines changed

8 files changed

+267
-5
lines changed

content/Computer Science/1 Foundations & Theory/Algorithms/DP 유형.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ modified: 2025/5/05 21:04:32
2828
- 트리/그래프 구조 → 트리 DP, 비트마스크 DP
2929
- 선형, 2D, 구간, 트리, 상태, 그리디, 케이스-분할(분기형)
3030

31+
- 최적 부분 구조, 중복 부분 문제 파악
32+
- 상태 정의
33+
- 점화식 도출
34+
- 최종 목표 설정
35+
- 경우의 수
36+
- 초기 상태 설정
37+
3138
# 선형 DP (1D)
3239
- 순서대로 누적 / 선택
3340
- 피보나치, 최대 연속합, 계단 오르기
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
tags: ["ps/boj/silver/1", "ps/boj/silver", "cs/algorithms/dynamic-programming/ps","cs/algorithms/prefix-sum/ps"]
3+
---
4+
5+
# Problem
6+
- [https://www.acmicpc.net/problem/11660](https://www.acmicpc.net/problem/11660)
7+
8+
# Logic
9+
- psum 구하고
10+
- 행 기준으로 구간합 더하기
11+
12+
# My Code
13+
14+
```cpp title="boj/11660.cpp"
15+
16+
#include <vector>
17+
void solution()
18+
{
19+
int n, m;
20+
cin >> n >> m;
21+
22+
vector<vector<int>> t(n, vector<int>(n));
23+
vector<vector<int>> psum_t(n, vector<int>(n + 1, 0));
24+
25+
for (int y = 0; y < n; ++y) {
26+
for (int x = 0; x < n; ++x) {
27+
cin >> t[y][x];
28+
psum_t[y][x + 1] = t[y][x];
29+
}
30+
}
31+
32+
for (int y = 0; y < n; ++y) {
33+
for (int x = 1; x <= n; ++x) {
34+
psum_t[y][x] += psum_t[y][x - 1];
35+
36+
log(psum_t[y][x], " ");
37+
}
38+
log("\n");
39+
}
40+
41+
while (m--) {
42+
int s_x, s_y, e_x, e_y;
43+
44+
cin >> s_x >> s_y >> e_x >> e_y;
45+
46+
int sum = 0;
47+
48+
// for (int y = s_y - 1; y < e_y; ++y) {
49+
// sum += psum_t[y][e_x] - psum_t[y][s_x - 1];
50+
// }
51+
for (int x = s_x - 1; x < e_x; ++x) {
52+
sum += psum_t[x][e_y] - psum_t[x][s_y - 1];
53+
}
54+
55+
cout << sum << '\n';
56+
}
57+
}
58+
59+
60+
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
tags: ["ps/boj/bronze/1", "ps/boj/bronze", "cs/algorithms/mathematics/ps","cs/algorithms/implementation/ps","cs/algorithms/bruteforcing/ps","cs/algorithms/arithmetic/ps"]
3+
---
4+
5+
# Problem
6+
- [https://www.acmicpc.net/problem/14626](https://www.acmicpc.net/problem/14626)
7+
8+
# Logic
9+
- 자리별 bias 곱하고 더하기
10+
- 체크자리 포함해서 비교
11+
12+
# My Code
13+
14+
```cpp title="boj/14626.cpp"
15+
16+
#include <vector>
17+
void solution()
18+
{
19+
string s;
20+
cin >> s;
21+
22+
int answer_bias = 1;
23+
int sum = 0;
24+
25+
for (size_t i = 0; i < s.length(); ++i) {
26+
if (s[i] == '*') {
27+
if (i & 1) {
28+
answer_bias = 3;
29+
}
30+
continue;
31+
}
32+
33+
if (i & 1) {
34+
sum += (s[i] - '0') * 3;
35+
} else {
36+
sum += (s[i] - '0');
37+
}
38+
}
39+
40+
int remain = 10 - (sum % 10);
41+
if (answer_bias == 1) {
42+
cout << remain % 10;
43+
} else {
44+
for (int i = 0; i <= 9; ++i) {
45+
if ((i * 3 + sum) % 10 == 0) {
46+
cout << i;
47+
break;
48+
}
49+
}
50+
}
51+
}
52+
53+
54+
```

content/Computer Science/1 Foundations & Theory/Algorithms/ps/boj/18111/18111.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ tags: ["ps/boj/silver/2", "ps/boj/silver", "cs/algorithms/bruteforcing/ps","cs/a
66
- [https://www.acmicpc.net/problem/18111](https://www.acmicpc.net/problem/18111)
77

88
# Logic
9+
- bruteforce
10+
- $m * n * 256 < 1억 $ = bruteforce
11+
- 모든 높이에 대해서 최소 도출
12+
- optimize
13+
- 평균을 기준으로 이동
14+
- 구현이 많아서 비추천
915

1016
# My Code
1117

@@ -14,6 +20,44 @@ tags: ["ps/boj/silver/2", "ps/boj/silver", "cs/algorithms/bruteforcing/ps","cs/a
1420
#include <vector>
1521
void solution()
1622
{
23+
int n, m, b;
24+
cin >> n >> m >> b;
25+
vector<vector<int>> map(n, vector<int>(m));
26+
27+
for (int i = 0; i < n; ++i) {
28+
for (int j = 0; j < m; ++j) {
29+
cin >> map[i][j];
30+
}
31+
}
32+
33+
int answer = C_MAX;
34+
int height = 256;
35+
36+
for (int test = 0; test <= 256; ++test) {
37+
int time = 0;
38+
int temp_b = b;
39+
40+
for (const auto& y : map) {
41+
for (const auto& x : y) {
42+
int gap = abs(test - x);
43+
44+
if (test >= x) {
45+
time += gap;
46+
temp_b -= gap;
47+
} else {
48+
time += (2 * gap);
49+
temp_b += gap;
50+
}
51+
}
52+
}
53+
54+
if (temp_b >= 0 && time <= answer) {
55+
answer = time;
56+
height = test;
57+
}
58+
}
59+
60+
cout << answer << " " << height;
1761
}
1862

1963

quartz.layout.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export const defaultContentPageLayout: PageLayout = {
6161
},
6262
{ Component: Component.Darkmode() },
6363
{ Component: Component.Mindmap({ mode: "button", localOptions: {} }) },
64-
{ Component: Component.Slide() }
64+
{
65+
Component: Component.Slide({
66+
tags: false
67+
})
68+
}
6569
],
6670
},
6771
),
@@ -120,7 +124,11 @@ export const defaultListPageLayout: PageLayout = {
120124
},
121125
{ Component: Component.Darkmode() },
122126
{ Component: Component.Mindmap({ mode: "button", localOptions: {} }) },
123-
{ Component: Component.Slide() }
127+
{
128+
Component: Component.Slide({
129+
tags: false
130+
})
131+
}
124132
],
125133
}),
126134
Component.Explorer({

quartz/components/Slide.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface SlideOptions {
1818
enabled: boolean,
1919
},
2020
includePresenterNotes: boolean,
21+
tags: boolean,
22+
index: boolean
2123
}
2224

2325
const defaultOptions: SlideOptions = {
@@ -33,6 +35,8 @@ const defaultOptions: SlideOptions = {
3335
enabled: true,
3436
},
3537
includePresenterNotes: true,
38+
tags: true,
39+
index: true,
3640
}
3741

3842
export default ((opts?: Partial<SlideOptions>) => {

quartz/components/scripts/slide.inline.ts

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,64 @@ function handleFootnote(data: string, separator: string) {
181181
}
182182
)
183183

184+
return slides.join(separator)
185+
}
186+
187+
function handleIndex(data: string, separator: string, option: SlideOptions, index: string) {
188+
const slides = data.split(separator)
189+
190+
if (!option.index) return slides.join("\n---\n");
191+
slides.splice(1, 0, index)
192+
193+
const indexMap = new Map<string, number>()
194+
const regex = /<h1[^>]*id="[^"]*"[^>]*>(.*?)<\/h1>/g;
195+
const tempDiv = document.createElement('div');
196+
197+
slides.forEach((slide, index) => {
198+
let match
199+
while ((match = regex.exec(slide)) !== null) {
200+
const fullH1Html = match[0];
201+
tempDiv.innerHTML = fullH1Html;
202+
const h1Element = tempDiv.querySelector('h1');
203+
204+
if (h1Element && h1Element.firstChild) {
205+
const content = h1Element.firstChild.textContent?.trim();
206+
207+
if (content) {
208+
indexMap.set(content, index + 1);
209+
}
210+
}
211+
}
212+
})
213+
214+
if (slides.length > 2) {
215+
slides[1] = slides[1].replace(
216+
/<a\s+([^>]*?)data-href="([^"]*)" ([^>]*)>/g,
217+
(fullMatch, beforeHref, dataHref, afterHref) => {
218+
if (indexMap.has(dataHref)) {
219+
return `<a ${beforeHref}href="#${indexMap.get(dataHref)}"${afterHref}>`
220+
}
221+
return fullMatch
222+
}
223+
)
224+
}
225+
184226
return slides.join("\n---\n")
185227
}
186228

229+
function makeIndex() {
230+
231+
const headers = document.querySelectorAll('article.popover-hint h1[id]');
232+
const index = Array.from(headers).map(head => `<li><a data-href="${head.textContent}" class="">${head.textContent}</a></li>`).join('')
233+
234+
return `
235+
<h1 class="slide-index-title">Index</h1>
236+
<ul class="slide-index-list" >
237+
${index}
238+
</ul>
239+
`
240+
}
241+
187242
function appendRemark(option: SlideOptions) {
188243

189244
const header = `${document.querySelector(".page-header h1.article-title")?.outerHTML}`
@@ -202,9 +257,12 @@ function appendRemark(option: SlideOptions) {
202257
anchorBlank(
203258
unwrapSlideNote(
204259
unwrapFootnotesSection(
205-
handleFootnote(
206-
injectSeparators(header + tags + body, separator),
207-
separator
260+
handleIndex(
261+
handleFootnote(
262+
injectSeparators(header + (option.tags ? tags : "") + body, separator),
263+
separator
264+
),
265+
separator, option, makeIndex()
208266
)
209267
)
210268
)
@@ -256,6 +314,8 @@ function paramOption(defaultOption: SlideOptions) {
256314
enabled: getBool("enabled", defaultOption.timer.enabled),
257315
},
258316
includePresenterNotes: getBool("includePresenterNotes", defaultOption.includePresenterNotes),
317+
tags: getBool("tags", defaultOption.tags),
318+
index: getBool("index", defaultOption.index),
259319
} as SlideOptions)
260320
}
261321

quartz/styles/custom.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,13 @@ hr {
383383
.remark-slide-content {
384384
background-color: var(--light);
385385

386+
&:first-of-type {
387+
padding: 0rem 4rem;
388+
display: flex;
389+
flex-direction: column;
390+
height: 100%;
391+
}
392+
386393
h1,
387394
h2,
388395
h3,
@@ -408,9 +415,27 @@ hr {
408415
}
409416
}
410417

418+
.slide-index-list {
419+
font-size: x-large;
420+
margin: 0 auto;
421+
margin-top: 1rem;
422+
}
423+
424+
.slide-index-title {
425+
display: grid;
426+
justify-content: center;
427+
428+
&:before {
429+
content: ""
430+
}
431+
}
432+
411433
.article-title {
412434
display: grid;
413435
justify-content: center;
436+
margin: 0;
437+
padding: 0;
438+
flex-grow: 1;
414439

415440
&:before {
416441
content: ""

0 commit comments

Comments
 (0)