Skip to content

Commit 9ee1ae7

Browse files
committed
Quartz sync: Oct 12, 2025, 3:45 PM
1 parent 87a4ff2 commit 9ee1ae7

File tree

4 files changed

+233
-29
lines changed

4 files changed

+233
-29
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
tags: ["ps/boj/platinum/5", "ps/boj/platinum", "cs/algorithms/dynamic-programming/ps","cs/algorithms/graph-theory/ps","cs/algorithms/shortest-path/ps","cs/algorithms/dijkstra's/ps"]
3+
---
4+
5+
# Problem
6+
- [https://www.acmicpc.net/problem/1162](https://www.acmicpc.net/problem/1162)
7+
- [code on boj](https://www.acmicpc.net/status?problem_id=1162&user_id=hiatus4322)
8+
- [code on github](https://github.com/codeyoma/ps/tree/main/boj/1162)
9+
10+
11+
<br/>
12+
13+
<!--
14+
# Logic
15+
16+
### *분석*
17+
- 문제 유형 (알고리즘...)
18+
- 제약 조건 (인풋 크기, 예외 값, 시공간 복잡도...)
19+
20+
### *설계*
21+
1. 알고리즘 선택
22+
2. 자료구조 선택
23+
3. 수도 코드 작성
24+
4. 정합판단
25+
- `1 ~ 3`과정으로 도출된 로직이 문제를 해결하는가
26+
- 그렇다 -> **구현**
27+
- 잘 모르겠다 -> **구현**
28+
- 아니다 -> 1번부터 다시 점검
29+
30+
### *구현*
31+
- 로직 검증
32+
33+
### *테스트*
34+
- 예외 케이스 고려
35+
36+
<br/>
37+
38+
-->
39+
40+
# My Code
41+
42+
## cpp
43+
```cpp title="boj/1162.cpp"
44+
// https://www.acmicpc.net/problem/1162
45+
#include <iostream>
46+
using namespace std;
47+
48+
#ifdef LOCAL
49+
# define LOG clog
50+
#else
51+
struct nullstream : ostream {
52+
nullstream()
53+
: ostream(nullptr) {}
54+
};
55+
nullstream LOG;
56+
#endif
57+
58+
void fast_io() {
59+
ios_base::sync_with_stdio(false);
60+
cin.tie(nullptr);
61+
}
62+
63+
//--------------------------------------------------------------------------------------------------
64+
65+
#define MAX (1234567891)
66+
#define MIN (-1234567891)
67+
68+
#include <algorithm>
69+
#include <iostream>
70+
#include <limits>
71+
#include <queue>
72+
#include <vector>
73+
74+
typedef struct dijk {
75+
unsigned long long dist;
76+
int v;
77+
int k;
78+
79+
bool operator<(const dijk& b) const {
80+
if (dist != b.dist) {
81+
return dist > b.dist;
82+
}
83+
return false;
84+
}
85+
} D;
86+
87+
int main() {
88+
fast_io();
89+
90+
int n, m, k;
91+
cin >> n >> m >> k;
92+
93+
vector<vector<pair<int, int>>> adj(n + 1);
94+
95+
for (int i = 0; i < m; ++i) {
96+
int u, v, w;
97+
cin >> u >> v >> w;
98+
adj[u].push_back({ v, w });
99+
adj[v].push_back({ u, w });
100+
}
101+
102+
priority_queue<D, vector<D>> pq;
103+
vector<vector<unsigned long long>> dist(n + 1, vector<unsigned long long>(k + 1, numeric_limits<long long>::max()));
104+
105+
// logic
106+
107+
pq.push({ 0, 1, 0 });
108+
dist[1][0] = 0;
109+
110+
while (!pq.empty()) {
111+
auto [d, v, used_k] = pq.top();
112+
pq.pop();
113+
114+
if (dist[v][used_k] != d) {
115+
continue;
116+
}
117+
118+
for (const auto& [u, w]: adj[v]) {
119+
// not take k
120+
if (dist[u][used_k] > d + w) {
121+
dist[u][used_k] = d + w;
122+
pq.push({ dist[u][used_k], u, used_k });
123+
}
124+
125+
// take k
126+
if (used_k < k && dist[u][used_k + 1] > d) {
127+
dist[u][used_k + 1] = d;
128+
pq.push({ dist[u][used_k + 1], u, used_k + 1 });
129+
}
130+
}
131+
}
132+
133+
unsigned long long answer = numeric_limits<long long>::max();
134+
135+
for (int i = 0; i <= k; ++i) {
136+
answer = min(answer, dist[n][i]);
137+
}
138+
cout << answer;
139+
}
140+
141+
```
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
tags: ["ps/boj/gold/5", "ps/boj/gold", "cs/algorithms/implementation/ps","cs/algorithms/greedy/ps","cs/algorithms/simulation/ps"]
3+
---
4+
5+
# Problem
6+
- [https://www.acmicpc.net/problem/33507](https://www.acmicpc.net/problem/33507)
7+
- [code on boj](https://www.acmicpc.net/status?problem_id=33507&user_id=hiatus4322)
8+
- [code on github](https://github.com/codeyoma/ps/tree/main/boj/33507)
9+
10+
11+
<br/>
12+
13+
# Logic
14+
15+
### *분석*
16+
- 문제 유형 (알고리즘...)
17+
- 제약 조건 (인풋 크기, 예외 값, 시공간 복잡도...)
18+
19+
### *설계*
20+
1. 알고리즘 선택
21+
2. 자료구조 선택
22+
3. 수도 코드 작성
23+
4. 정합판단
24+
- `1 ~ 3`과정으로 도출된 로직이 문제를 해결하는가
25+
- 그렇다 -> **구현**
26+
- 잘 모르겠다 -> **구현**
27+
- 아니다 -> 1번부터 다시 점검
28+
29+
### *구현*
30+
- 로직 검증
31+
32+
### *테스트*
33+
- 예외 케이스 고려
34+
35+
<br/>
36+
37+
# My Code
38+
39+
## cpp
40+
```cpp title="boj/33507.cpp"
41+
// https://www.acmicpc.net/problem/33507
42+
#include <iostream>
43+
using namespace std;
44+
45+
#ifdef LOCAL
46+
#define LOG clog
47+
#else
48+
struct nullstream : ostream {
49+
nullstream() : ostream(nullptr) {}
50+
};
51+
nullstream LOG;
52+
#endif
53+
54+
void fast_io() {
55+
ios_base::sync_with_stdio(false);
56+
cin.tie(nullptr);
57+
}
58+
59+
//--------------------------------------------------------------------------------------------------
60+
61+
#define MAX (1234567891)
62+
#define MIN (-1234567891)
63+
64+
#include <iostream>
65+
66+
int main() {
67+
fast_io();
68+
69+
// logic
70+
}
71+
72+
```

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
# Problem
55

6+
67
<br/>
78

9+
<!--
810
# Logic
911
1012
### *분석*
@@ -29,4 +31,6 @@
2931
3032
<br/>
3133
34+
-->
35+
3236
# My Code

package-lock.json

Lines changed: 16 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)