| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 31217 |
| 문제명 | Y |
| 레벨 | 실버 3 |
| 분류 |
그래프 |
| 시간복잡도 | O(V+E) |
| 인풋사이즈 | V<=10^5, E<=2*10^5 |
| 사용한 언어 | Python 3.11 |
| 제출기록 | 34024KB / 228ms |
| 최고기록 | 208ms |
| 해결날짜 | 2024/01/08 |
"""Solution code for "BOJ 31217. Y".
- Problem link: https://www.acmicpc.net/problem/31217
- Solution link: http://www.teferi.net/ps/problems/boj/31217
Tags: [graph]
"""
import math
import sys
MOD = 10**9 + 7
def main():
n, m = [int(x) for x in sys.stdin.readline().split()]
degrees = [0] * n
for _ in range(m):
u, v = [int(x) - 1 for x in sys.stdin.readline().split()]
degrees[u] += 1
degrees[v] += 1
answer = sum(math.comb(d, 3) for d in degrees) % MOD
print(answer)
if __name__ == '__main__':
main()