P9850 [ICPC 2021 Nanjing R] Ancient Magic Circle in Teyvat

题目描述

Astrologist Mona Megistus discovers an ancient magic circle in Teyvat recently. ![](https://cdn.luogu.com.cn/upload/image_hosting/gohzab6t.png) The magic circle looks like a complete graph with $n$ vertices, where $m$ edges are colored red and other edges are colored blue. Note that a complete graph is a simple undirected graph in which every pair of distinct vertices is connected by a unique edge. Mona realizes that if she chooses four different vertices such that the six edges between these four vertices are of the same color, she will get a *key* from the magic circle. If the color is red, she will get a *red key*, and if the color is blue, she will get a *blue key*. Base on the information written in the ancient books Mona has read, the magic power of the ancient magic circle is the absolute difference between the number of *red keys* and the number of the number of *blue keys* she can get from the magic circle. Mona needs your help badly, since calculating the magic power of the magic circle is really a tough job.

输入格式

输出格式

说明/提示

For the sample case, there is only one *red key* $(1,2,3,4)$ and there are four *blue keys* $(1,5,6,7)$, $(2,5,6,7)$, $(3,5,6,7)$ and $(4,5,6,7)$ in the ancient magic circle, thus the magic power of the magic circle is $|1-4|=3$.