Skip to content

Commit

Permalink
Create 0422.cpp14.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pukuba committed Dec 17, 2020
1 parent 950c947 commit 5289c7d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions boj/02422/0422.cpp14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <bits/stdc++.h>

using namespace std;
int n, m, ans;
vector<int> v[202];
int go(int i, int j, int k)
{
bool i_j = binary_search(v[i].begin(), v[i].end(), j);
bool i_k = binary_search(v[i].begin(), v[i].end(), k);
bool j_k = binary_search(v[j].begin(), v[j].end(), k);
if (!i_j && !i_k && !j_k)
return 1;
return 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
int x, y;
cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
for (int i = 1; i <= n; i++)
sort(v[i].begin(), v[i].end());
for (int i = 1; i <= n; i++)
{
for (int j = i + 1; j <= n; j++)
{
for (int k = j + 1; k <= n; k++)
{
ans += go(i, j, k);
}
}
}
cout << ans << '\n';
}

0 comments on commit 5289c7d

Please sign in to comment.