From fe794a0f074475b66984379dc083e64c810fb99f Mon Sep 17 00:00:00 2001 From: oncsr Date: Tue, 9 Dec 2025 23:35:17 +0900 Subject: [PATCH] =?UTF-8?q?[20251209]=20BOJ=20/=20G4=20/=20=EC=9E=90?= =?UTF-8?q?=EB=B2=8C=EB=A0=88=20=EC=84=B8=EA=B8=B0=20/=20=EA=B6=8C?= =?UTF-8?q?=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\240\210 \354\204\270\352\270\260.md" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "khj20006/202512/09 BOJ G4 \354\236\220\353\262\214\353\240\210 \354\204\270\352\270\260.md" diff --git "a/khj20006/202512/09 BOJ G4 \354\236\220\353\262\214\353\240\210 \354\204\270\352\270\260.md" "b/khj20006/202512/09 BOJ G4 \354\236\220\353\262\214\353\240\210 \354\204\270\352\270\260.md" new file mode 100644 index 00000000..ab78ece1 --- /dev/null +++ "b/khj20006/202512/09 BOJ G4 \354\236\220\353\262\214\353\240\210 \354\204\270\352\270\260.md" @@ -0,0 +1,28 @@ +```cpp +#include +using namespace std; +using ll = long long; + +int N; +ll deg[300001]{}; +vector> edges; + +int main(){ + cin.tie(0)->sync_with_stdio(0); + + cin>>N; + edges.resize(N-1); + for(auto &[a,b] : edges) { + cin>>a>>b; + deg[a]++; + deg[b]++; + } + + ll ans = 0; + for(auto [a,b] : edges) if(min(deg[a], deg[b]) >= 3) { + ans += ((deg[a] - 1) * (deg[a] - 2) / 2) * ((deg[b] - 1) * (deg[b] - 2) / 2); + } + cout<