This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
typedef long long llong;
const int MAXN = 5000 + 10;
const llong INF = 1e18;
const int INTINF = 1e9;
int n, m;
bool c[MAXN][MAXN];
void solve()
{
for (int i = 1 ; i <= n ; ++i)
{
for (int j = i + 1 ; j <= n ; ++j)
{
if (!c[i][j])
{
continue;
}
for (int k = i + 1 ; k <= n ; ++k)
{
if (!c[i][k] || j == k)
{
continue;
}
c[j][k] = true;
}
}
}
int cnt = 0;
for (int i = 1 ; i <= n ; ++i)
{
for (int j = i + 1 ; j <= n ; ++j)
{
cnt += c[i][j];
}
}
std::cout << cnt << '\n';
}
void input()
{
std::cin >> n >> m;
for (int i = 1 ; i <= m ; ++i)
{
int u, v;
std::cin >> u >> v;
c[u][v] = true;
c[v][u] = true;
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |