์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- GCP
- ๋์ ํฉ
- java
- BFS
- ๋งต
- Spring
- dfs
- DP
- thymeleaf
- ์ต๋จ ๊ฒฝ๋ก
- ๋ถํ ์ ๋ณต
- web
- JPA
- ์๋ฎฌ๋ ์ด์
- error
- dynamic debugging
- Reversing
- ์คํ
- ์ฐ์ ์์ ํ
- OS
- ๊ตฌํ
- ๋ฐ์ดํฌ์คํธ๋ผ
- c++
- CVE
- ๋ฐฑํธ๋ํน
- ๊ทธ๋ฆฌ๋
- ์ฌ๊ท
- ์ด๋ถ ํ์
- ๋ฌธ์์ด
- ์์ ์ ๋ ฌ
- Today
- Total
๋ชฉ๋ก๐ PS (125)
hades
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/17626 ๐ ์ค๊ณ ๋ชจ๋ ์์ฐ์๋ ๋ท ํน์ ๊ทธ ์ดํ์ ์ ๊ณฑ์์ ํฉ์ผ๋ก ํํํ ์ ์์ผ๋ฏ๋ก, ๊ทธ ์์ฐ์๋ฅผ ์ด๋ฃจ๋ ์ ๊ณฑ์๋ค์ ์๋ ๋ค์ด๋๋ฏน ํ๋ก๊ทธ๋๋ฐ์ ์ด์ฉํ์ฌ ๊ตฌํ ์ ์๋ค. ์๋ฅผ ๋ค์ด, 61 = 5^2 + 6^2์ด๋ฏ๋ก 5^2์ ์ต์ ์ ๊ณฑ์ ๊ฐ์์ธ 1๊ณผ 6^2์ ์ต์ ์ ๊ณฑ์ ๊ฐ์์ธ 1์ ๋ํด ์ ๊ณฑ์ 2๊ฐ๋ฅผ ์ด์ฉํ์ฌ ๊ตฌํ ์ ์๋ค. ๐ ํ์ด#include #include #include #include using namespace std;int n;vector dp(50001, 1e9 + 7);int main(void){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ..
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/14500 ๐ ์ค๊ณ์ฒ์์๋ ์์ ์ขํ๋ฅผ ์ก๊ณ , ๊ทธ ์ขํ์์ ์์ํ๋ ํ ํธ๋ก๋ฏธ๋ ธ ์ผ์ด์ค๋ฅผ ๋ชจ๋ ๋ง๋ค์ด์ ๊ฐ์ ๋์ถํ๋ ค ํ์ผ๋, ๋์นญ๊ณผ ํ์ ๊น์ง ๊ณ ๋ คํ์ ๋, ์ผ์ด์ค๊ฐ ๋๋ฌด ๋ง์์ง๋ค. ํ ํธ๋ก๋ฏธ๋ ธ์ ํน์ง์ ์ธ์ ํ ์นธ์ผ๋ก ์ด๋ฃจ์ด์ ธ ์๋ค๋ ๊ฒ์ด๋ค. ๋ฐ๋ผ์, DFS๋ฅผ ์ด์ฉํ์ฌ 4๊ฐ์ ์นธ์ผ๋ก ์ด๋ฃจ์ด์ง ํ ํธ๋ก๋ฏธ๋ ธ๋ฅผ ๋ง๋ค ์ ์๋ค. (poli) ํ์ง๋ง, ใ ๋ชจ์์ ํ ํธ๋ก๋ฏธ๋ ธ๋ ์ธ์ ํ ์นธ์ผ๋ก ํ์ฅํด๋๊ฐ๋ DFS๋ก ๊ตฌํ ์ ์์ผ๋ฏ๋ก, ๋ฐ๋ก ๋ง๋ค์ด์ผ ํ๋ค. ใ ๋ชจ์์ ๋ง๋๋ ๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ ๅ ๋ชจ์์ ํ ํธ๋ก๋ฏธ๋ ธ๋ฅผ ๋ง๋ค๊ณ , ์ํ์ข์ฐ์์ ํ๋์ฉ ๋นผ๋ฉด ๋๋ค. ๅ ๋ชจ์์ ๊ตฌ์ฑํ๋๋ฐ, ์นธ์ด ์กด์ฌํ ์ ์๋ ๋ฒ์๋ฅผ ๋ฒ์ด๋๋ ๊ฒฝ์ฐ์๋ ์ ์ธ๋์๋ค๊ณ ์๊ฐํ๋ฉด ๋๊ณ , ์ ์ธ๋..

๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/11726 ๐ ์ค๊ณ์ง์ ๊ทธ๋ ค์ ํ์ ํด๋ณด๋ฉด, ํ๋์ ํ์ดํ๋ 2*1 ํ์ผ์ ์ถ๊ฐํ์ฌ ๋ง๋ค์ด์ง๊ณ , ๋นจ๊ฐ์ ํ์ดํ๋ 1*2 ํ์ผ์ ๋ ๊ฐ ๋ถ์ธ ๊ฒ์ ์ถ๊ฐํ์ฌ ๋ง๋ค์ด์ง๋ค. ์ฆ, dp[i] = dp[i-1] + dp[i-2]๋ผ๋ ๊ฒ์ ์ ์ ์๋ค. ๐ ํ์ด#include #include #include #include using namespace std;int n;vector dp(1001);int main(void){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; dp[1] = 1; dp[2] = 2; for (int i = 3; i
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/11724 ๐ ์ค๊ณ์๋ก์ ์งํฉ์ ์ฌ์ฉํ์ฌ ์ฐ๊ฒฐ๋ ๊ฒ๋ค๋ผ๋ฆฌ ๊ทธ๋ฃน์ ํ์ฑํ๊ฒ ํ๋ค. ๊ทธ๋ฃน์ ์๋ ๋งจ ๊ผญ๋๊ธฐ์ ์๋ ์กฐ์์ ์์ด๋ค. ๋ฌธ์ ์ ๋ ฅ ์์์ ๋ฐ๋ผ parent[x]๊ฐ ๋งจ ๊ผญ๋๊ธฐ ์กฐ์์ด ์๋ ์ ์์ผ๋ฏ๋ก, find_parent(x)๋ก ๋งจ ๊ผญ๋๊ธฐ ์กฐ์์ ์งํฉ์ ์ฝ์ ํ๋ค. BFS๋ก ๋ฐฉ๋ฌธ์ฒ๋ฆฌ๋ฅผ ํ์ฌ ์์ญ์ ๊ฐ์๋ฅผ ๊ตฌํ์ฌ ํด๊ฒฐํ ์๋ ์๋ค. ๐ ํ์ด1#include #include #include #include using namespace std;int n, m, u, v;vector parent(1001);set result;int find_parent(int x) { if (parent[x] != x) { return find_pa..
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/11659 ๐ ์ค๊ณi๋ฒ์งธ๋ถํฐ j๋ฒ์งธ๊น์ง์ ํฉ์ j๋ฒ์งธ๊น์ง์ ๋์ ํฉ์์ i-1๋ฒ์งธ๊น์ง์ ๋์ ํฉ์ ๋นผ๋ฉด ๋๋ค. ์ฃผ์ํ ๊ฒ์ ๋ฐฐ์ด์ 0๋ถํฐ ์์ํ์ง๋ง, ์ ๋ ฅ์ผ๋ก ๋ค์ด์ค๋ ๊ฒ์ ๋ช ๋ฒ์งธ์ ๋ํ ์ ๋ณด์ด๋ฏ๋ก 1๋ถํฐ ์์ํ๋ค. ๐ ํ์ดpackage hades.ps;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, m; n = sc.nextInt(); m = sc.nextInt(); int[] arr..
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/11403 ๐ ์ค๊ณ๋ชจ๋ i, j ์์ ๋ํ์ฌ i์์ j๋ก ์ด๋ํ ์ ์๋์ง ๋ฌป๊ณ ์์ผ๋ฏ๋ก, i์์ j๊น์ง ๊ฐ๋๋ฐ ๊ฑฐ๋ฆฌ๊ฐ 0๋ณด๋ค ํฌ๊ธฐ๋ง ํ๋ฉด ๋๋ค. ๋ชจ๋ ์์ ๋ํ ์ต๋จ ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ๋ ํ๋ก์ด๋ ์์ ์๊ณ ๋ฆฌ์ฆ์ ์ด์ฉํ์ฌ i์ j๊ฐ ์ฐ๊ฒฐ๋์ด ์๋์ง ํ์ธํ ๋, ์ค๊ฐ์ง์ ์ธ k๋ฅผ ์ค์ ํ๊ณ , i์ k, k์ j๊ฐ ์ฐ๊ฒฐ๋์ด ์์ผ๋ฉด i์ j๊ฐ ์ฐ๊ฒฐ๋์ด ์๋ ๊ฒ์ผ๋ก ๊ฐฑ์ ํ๋ค. ๐ ํ์ด#include #include #include using namespace std;int n, temp;vector> adj_matrix(100, vector(100));int main(void){ ios_base::sync_with_stdio(false); cin...
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/11399 ๐ ์ค๊ณ์ธ์ถํ๋๋ฐ ์๊ฐ์ ๋ง์ด ์ฐ๋ ์ฌ๋์ด ์์ ์ค๋ฉด, ๋ค์ ์ฌ๋๋ค์ด ๊ธฐ๋ค๋ ค์ผ ํ๋ ์๊ฐ์ด ๊ทธ๋งํผ ๋์ด๋๋ฏ๋ก, ์ธ์ถ ์๊ฐ์ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌํ๋ค. ์ด๋ค ์ฌ๋์ด ์ธ์ถํ๋๋ฐ๊น์ง ๊ฑธ๋ฆฌ๋ ์๊ฐ์ ์ ์ฌ๋๋ค์ด ์ธ์ถํ๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ + ๋ณธ์ธ์ด ์ธ์ถํ๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ์ด๋ค. ๐ ํ์ด#include #include #include using namespace std;int n;vector p;int main(void){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; p = vector(n); for (int i = 0; i > p[i]; } sort(p.begin(..
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/11286 ๐ ์ค๊ณ์ฐ์ ์์ ํ๋ฅผ ์ฌ์ฉํ์ฌ ์ฒซ ๋ฒ์งธ ์กฐ๊ฑด์ผ๋ก ์ ๋๊ฐ์ ๋น๊ตํ๊ณ , ๋ ๋ฒ์งธ ์กฐ๊ฑด์ผ๋ก ์ ๋๊ฐ์ด ๊ฐ๋ค๋ฉด ์ค์ ๊ฐ์ ๋น๊ตํ์ฌ ์์ ๊ฒ์ด ์ฐ์ ์์๊ฐ ๋๋๋ก ํ๋ค. ๐ ํ์ด#include #include #include using namespace std;int n, x;struct compare { bool operator()(int a, int b) { if (abs(a) > abs(b)) { return true; } else if (abs(a) == abs(b)) { return a > b; } else { return false; } }};priority_queue, compare> pq;int mai..
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/10026 ๐ ์ค๊ณ์ํ์ข์ฐ๋ก ์ธ์ ํ ์์ญ ์ค ๊ฐ์ ์์ ๊ฐ์ง๋ค๋ฉด ํ ๊ตฌ์ญ์ผ๋ก ์ธ์ํ๋ค๋ ๊ฒ์์ BFS์์ ์์์ฐจ๋ฆด ์ ์๋ค. ์ ๋ก์์ฝ์ธ ์ฌ๋๊ณผ ์ ๋ก์์ฝ์ด ์๋ ์ฌ๋์ ๊ฒฝ์ฐ๋ฅผ ๋๋์ด์ BFS๋ฅผ ์ํํ๋ค. ์ ๋ก์์ฝ์ด ์๋๋ผ๋ฉด, BFS๊ฐ ์์๋๋ ์ง์ ์ ์๊น๊ณผ ๊ฐ์์ผ ํ ๊ตฌ์ญ์ ํฌํจ๋๊ณ , ์ ๋ก์์ฝ์ด๋ผ๋ฉด ์์๋๋ ์ง์ ์ ์๊น์ด ๋นจ๊ฐ์ ๋๋ ์ด๋ก์์ด๋ฉด, ์ด์ํ ์ง์ ์ ์๊น๋ ๋นจ๊ฐ์ ๋๋ ์ด๋ก์์ด๋ฉด ํ ๊ตฌ์ญ์ ํฌํจ๋๊ณ , ํ๋์์๋ฉด ์ด์ํ ์ง์ ์ ์๊น๋ ํ๋์์ด์ด์ผ ํ๋ค. ๐ ํ์ด#include #include #include using namespace std;int n;vector> painting1(100, vector(100));vector..
๐ฅ ๋ฌธ์ https://www.acmicpc.net/problem/9095 ๐ ์ค๊ณ1 = 12 = 1 + 1 = 23 = 1 + 1 + 1 = 2 + 1 = 1 + 2 = 34 = 1 + 1 + 1 + 1 = 2 + 1 + 1 = 1 + 2 + 1 = 3 + 1 = 1 + 1 + 2 = 2 + 2 = 1 + 3์ผ๋ก dp[i] = dp[i-1]+dp[i-2]+dp[i-3]์ด๋ผ๋ ๊ฒ์ ์ ์ ์๋ค. dp[0]์ 0์ผ๋ก ์ด๊ธฐํํ๋ฉด, 1๋ถํฐ ๋ฐ๋ณต๋ฌธ์ ์์ํ ์ ์๋ค. ๋จ, ๋ฒ์๋ฅผ ์ฃผ์ํด์ผ ํ๋ค. ๐ ํ์ด#include #include using namespace std;int t, n;vector dp(11);int main(void){ dp[0] = 1; for (int i = 1; i = 0) { ..