結果

問題 No.1997 X Lighting
ユーザー MasKoaTSMasKoaTS
提出日時 2022-04-16 18:27:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 99,720 KB
最終ジャッジ日時 2023-08-26 20:11:07
合計ジャッジ時間 7,596 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,192 KB
testcase_01 AC 71 ms
71,216 KB
testcase_02 AC 71 ms
70,992 KB
testcase_03 AC 71 ms
71,484 KB
testcase_04 AC 71 ms
71,192 KB
testcase_05 AC 91 ms
76,732 KB
testcase_06 AC 101 ms
77,360 KB
testcase_07 AC 72 ms
71,212 KB
testcase_08 AC 82 ms
76,432 KB
testcase_09 AC 85 ms
76,360 KB
testcase_10 AC 71 ms
71,240 KB
testcase_11 AC 76 ms
75,280 KB
testcase_12 AC 71 ms
71,240 KB
testcase_13 AC 110 ms
77,572 KB
testcase_14 AC 190 ms
99,720 KB
testcase_15 AC 147 ms
82,036 KB
testcase_16 AC 157 ms
84,748 KB
testcase_17 AC 218 ms
94,156 KB
testcase_18 AC 176 ms
90,712 KB
testcase_19 AC 239 ms
99,004 KB
testcase_20 AC 255 ms
98,424 KB
testcase_21 AC 252 ms
98,484 KB
testcase_22 AC 244 ms
98,924 KB
testcase_23 AC 176 ms
93,464 KB
testcase_24 AC 109 ms
78,072 KB
testcase_25 AC 241 ms
98,088 KB
testcase_26 AC 218 ms
94,452 KB
testcase_27 AC 223 ms
95,148 KB
testcase_28 AC 137 ms
82,468 KB
testcase_29 AC 137 ms
81,488 KB
testcase_30 AC 242 ms
98,244 KB
testcase_31 AC 195 ms
93,728 KB
testcase_32 AC 129 ms
81,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
xst = set([]);	yst = set([])
for _ in [0] * m:
	X, Y = map(int, input().split())
	xst.add((X - 1) + (Y - 1))
	yst.add((X - 1) - (Y - 1))

lis = [[] for _ in [0] * 2]
for x in sorted(xst):
	lis[x & 1].append(x)

ans = 0
for x in xst:
	ans += min(x, n - 1) - max(-n + 1 + x, 0) + 1
for y in yst:
	b = abs(y) & 1
	ans += min(n - 1 + y, n - 1) - max(y, 0) + 1
	l = bisect_left(lis[b], max(y, -y))
	r = bisect_right(lis[b], min(2 * (n - 1) - y, 2 * (n - 1) + y))
	ans -= r - l

print(ans)
0