結果

問題 No.1997 X Lighting
ユーザー MasKoaTSMasKoaTS
提出日時 2022-04-16 13:24:50
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 833 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 26,252 KB
最終ジャッジ日時 2023-08-26 17:45:10
合計ジャッジ時間 13,970 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,020 KB
testcase_01 AC 19 ms
7,968 KB
testcase_02 AC 17 ms
8,004 KB
testcase_03 AC 19 ms
7,988 KB
testcase_04 AC 17 ms
8,076 KB
testcase_05 AC 27 ms
8,452 KB
testcase_06 AC 91 ms
8,724 KB
testcase_07 AC 17 ms
8,004 KB
testcase_08 AC 25 ms
8,356 KB
testcase_09 AC 21 ms
8,336 KB
testcase_10 AC 17 ms
8,096 KB
testcase_11 AC 18 ms
7,968 KB
testcase_12 AC 17 ms
8,092 KB
testcase_13 AC 145 ms
9,032 KB
testcase_14 AC 588 ms
26,192 KB
testcase_15 AC 207 ms
14,776 KB
testcase_16 AC 272 ms
15,380 KB
testcase_17 AC 634 ms
24,552 KB
testcase_18 AC 353 ms
16,028 KB
testcase_19 AC 752 ms
24,552 KB
testcase_20 AC 833 ms
26,252 KB
testcase_21 AC 814 ms
26,156 KB
testcase_22 AC 748 ms
24,556 KB
testcase_23 AC 405 ms
17,276 KB
testcase_24 AC 31 ms
8,720 KB
testcase_25 AC 792 ms
25,612 KB
testcase_26 AC 664 ms
25,112 KB
testcase_27 AC 689 ms
25,132 KB
testcase_28 AC 219 ms
15,236 KB
testcase_29 AC 215 ms
14,788 KB
testcase_30 AC 769 ms
25,252 KB
testcase_31 AC 499 ms
18,684 KB
testcase_32 AC 135 ms
10,964 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