Created
December 6, 2025 01:16
-
-
Save maehrm/dd86a33f6d29d685bea85dcdd8eba46e to your computer and use it in GitHub Desktop.
D - Line Crossing https://atcoder.jp/contests/abc402/tasks/abc402_d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| N, M = map(int, input().split()) | |
| d = defaultdict(int) | |
| for _ in range(M): | |
| A, B = map(int, input().split()) | |
| d[(A + B) % N] += 1 | |
| ans = M * (M - 1) // 2 | |
| for _, v in d.items(): | |
| ans -= v * (v - 1) // 2 | |
| print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment