From edd1e158b759a735579b10f892874868a3053140 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Fri, 12 Sep 2025 23:39:53 +0900 Subject: [PATCH] =?UTF-8?q?[20250912]=20PGM=20/=20LV2=20/=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=20=EC=BD=94=EB=93=9C=20=ED=95=B4=EB=8F=85=20/=20?= =?UTF-8?q?=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\223\234 \355\225\264\353\217\205.md" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "suyeun84/202509/12 PGM LV2 \353\271\204\353\260\200 \354\275\224\353\223\234 \355\225\264\353\217\205.md" diff --git "a/suyeun84/202509/12 PGM LV2 \353\271\204\353\260\200 \354\275\224\353\223\234 \355\225\264\353\217\205.md" "b/suyeun84/202509/12 PGM LV2 \353\271\204\353\260\200 \354\275\224\353\223\234 \355\225\264\353\217\205.md" new file mode 100644 index 00000000..4dbbc2c8 --- /dev/null +++ "b/suyeun84/202509/12 PGM LV2 \353\271\204\353\260\200 \354\275\224\353\223\234 \355\225\264\353\217\205.md" @@ -0,0 +1,39 @@ + ```java +import java.util.*; +class Solution { + static int answer = 0; + public int solution(int n, int[][] q, int[] ans) { + List list = new LinkedList<>(); + dfs(n, 1, list, q, ans); + + return answer; + } + + private void dfs(int n, int idx, List list, int[][] q, int[] ans) { + if (list.size() == 5) { + if(check(list, q, ans)) { + answer++; + } + return; + } + for (int i = idx; i <= n; i++) { + list.add(i); + dfs(n, i+1, list, q, ans); + list.remove(list.size() - 1); + } + } + + private boolean check(List list, int[][] q, int[] ans) { + int idx = 0; + for (int[] n : q) { + int cnt = 0; + for (int val : n) { + if (list.contains(val)) cnt++; + } + if (cnt != ans[idx]) return false; + idx++; + } + return true; + } +} +```