From fe8e1347fa3d3eaa752a23e56620342d178739dd Mon Sep 17 00:00:00 2001 From: Jihoon Lee Date: Fri, 23 Aug 2024 09:48:44 +0900 Subject: [PATCH] Add 02422.cpp --- 02xxx/02422.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 02xxx/02422.cpp diff --git a/02xxx/02422.cpp b/02xxx/02422.cpp new file mode 100644 index 00000000..382fed65 --- /dev/null +++ b/02xxx/02422.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include +using namespace std; + +struct pair_hash { + size_t operator()(const pair &p) const { + return (p.first << 16) ^ p.second; + } +}; + +void solve(void) { + int n, m; cin >> n >> m; + unordered_set, pair_hash> s; + while (m--) { + int a, b; cin >> a >> b; + if (a > b) swap(a, b); + s.insert({a, b}); + } + + int ans = 0; + for (int i=1; i<=n-2; i++) for (int j=i+1; j<=n-1; j++) for (int k=j+1; k<=n; k++) { + if (s.find({i, j}) == s.end() && s.find({j, k}) == s.end() && s.find({i, k}) == s.end()) { + ans++; + } + } + cout << ans; +} + +int main(void) { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + solve(); + return 0; +} \ No newline at end of file