using
System;
using
System.Collections.Generic;
using
System.Linq;
class
Program {
static
void
Main(
string
[] args)
{
int
N = 4;
List<Tuple<
int
,
int
> > edges
=
new
List<Tuple<
int
,
int
> >(N);
edges.Add(
new
Tuple<
int
,
int
>(1, 2));
edges.Add(
new
Tuple<
int
,
int
>(2, 3));
edges.Add(
new
Tuple<
int
,
int
>(1, 4));
Console.WriteLine(maxEdges(N, edges));
}
static
void
dfs(
int
node,
int
par,
bool
isBlack,
bool
[, ] adj,
bool
[] color)
{
color[node] = isBlack;
for
(
int
i = 1; i < adj.GetLength(0); i++)
{
if
(adj[node, i] ==
false
|| i == par)
continue
;
dfs(i, node, !isBlack, adj, color);
}
}
static
long
maxEdges(
int
n,
List<Tuple<
int
,
int
> > edges)
{
bool
[, ] adj =
new
bool
[n + 1, n + 1];
foreach
(Tuple<
int
,
int
> tuple
in
edges)
{
adj[tuple.Item1, tuple.Item2] =
true
;
adj[tuple.Item2, tuple.Item1] =
true
;
}
bool
[] color =
new
bool
[n + 1];
dfs(1, 0,
true
, adj, color);
long
ans = 0;
for
(
int
i = 1; i <= n; ++i)
{
for
(
int
j = i + 1; j <= n; ++j)
{
if
(color[i] != color[j]
&& adj[i, j] ==
false
)
ans++;
}
}
return
ans;
}
}