結果
問題 | No.1997 X Lighting |
ユーザー |
👑 |
提出日時 | 2022-07-01 22:07:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 315 ms / 2,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 95,808 KB |
最終ジャッジ日時 | 2024-11-26 05:17:47 |
合計ジャッジ時間 | 7,156 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
from bisect import bisect_left, bisect_rightn, m = map(int, input().split())X = set()Y = set()for _ in range(m):x, y = map(int, input().split())X.add(x + y)Y.add(x - y)ans = 0odd = []even = []for x in sorted(X):ans += min(x - 1, 2 * n - x + 1)if x & 1:odd.append(x)else:even.append(x)for y in Y:xx = 1yy = xx - yif yy <= 0:yy = 1xx = yy + ymi = xx + yyxx = nyy = xx - yif yy > n:yy = nxx = yy + yma = xx + yyif mi & 1:p1 = bisect_left(odd, mi)p2 = bisect_right(odd, ma)else:p1 = bisect_left(even, mi)p2 = bisect_right(even, ma)ans += (ma - mi) // 2 + 1 - (p2 - p1)print(ans)