結果
問題 |
No.1997 X Lighting
|
ユーザー |
![]() |
提出日時 | 2022-07-01 22:07:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,010 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 100,736 KB |
最終ジャッジ日時 | 2024-11-26 05:17:20 |
合計ジャッジ時間 | 5,320 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | WA * 30 |
ソースコード
mod = 998244353 def main(): import sys from bisect import bisect_left input = sys.stdin.readline N, M = map(int, input().split()) U0 = set() U1 = set() V0 = set() V1 = set() ans = 0 for _ in range(M): x, y = map(int, input().split()) u = x + y v = x - y if u & 1: U1.add(u) else: U0.add(u) if v & 1: V1.add(v) else: V0.add(v) ans += N - abs(N + 1 - u) ans += N - abs(v) ans -= 1 U0 = sorted(list(U0)) U1 = sorted(list(U1)) V0 = sorted(list(V0)) V1 = sorted(list(V1)) for u in U0: mi = max(2 - u, -2 * N + u) ma = min(2 * N - u, -2 + u) ans -= bisect_left(V0, ma + 1) - bisect_left(V0, mi) for u in U1: mi = max(2 - u, -2 * N + u) ma = min(2 * N - u, -2 + u) ans -= bisect_left(V1, ma + 1) - bisect_left(V1, mi) print(ans) if __name__ == '__main__': main()