結果

問題 No.1997 X Lighting
ユーザー MasKoaTSMasKoaTS
提出日時 2022-04-23 15:10:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 669 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 30,392 KB
最終ジャッジ日時 2023-09-07 07:53:10
合計ジャッジ時間 12,395 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,616 KB
testcase_01 AC 20 ms
8,552 KB
testcase_02 AC 19 ms
8,656 KB
testcase_03 AC 22 ms
8,616 KB
testcase_04 AC 19 ms
8,552 KB
testcase_05 AC 28 ms
8,740 KB
testcase_06 AC 92 ms
9,056 KB
testcase_07 AC 19 ms
8,584 KB
testcase_08 AC 27 ms
8,620 KB
testcase_09 AC 22 ms
8,708 KB
testcase_10 AC 20 ms
8,620 KB
testcase_11 AC 20 ms
8,676 KB
testcase_12 AC 20 ms
8,712 KB
testcase_13 AC 148 ms
9,156 KB
testcase_14 AC 490 ms
30,392 KB
testcase_15 AC 181 ms
15,728 KB
testcase_16 AC 237 ms
16,740 KB
testcase_17 AC 539 ms
26,120 KB
testcase_18 AC 301 ms
17,992 KB
testcase_19 AC 619 ms
27,868 KB
testcase_20 AC 664 ms
29,052 KB
testcase_21 AC 669 ms
29,232 KB
testcase_22 AC 636 ms
27,788 KB
testcase_23 AC 340 ms
19,096 KB
testcase_24 AC 31 ms
9,016 KB
testcase_25 AC 634 ms
28,600 KB
testcase_26 AC 546 ms
27,016 KB
testcase_27 AC 567 ms
27,004 KB
testcase_28 AC 191 ms
16,048 KB
testcase_29 AC 187 ms
16,044 KB
testcase_30 AC 623 ms
28,504 KB
testcase_31 AC 412 ms
20,564 KB
testcase_32 AC 121 ms
11,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
from collections import deque
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))

ans = 0
xlis = [[] for _ in [0] * 2]
for x in xst:
	ans += min(x, n - 1) - max(-n + 1 + x, 0) + 1
	xlis[x & 1].append(x)
for y in yst:
	ans += min(n - 1 + y, n - 1) - max(y, 0) + 1

que = [deque(sorted(lis)) for lis in xlis]
for y in sorted(abs(y) for y in yst):
	lv, rv = y, 2 * (n - 1) - y
	b = y & 1
	while(que[b] and que[b][-1] > rv):
		que[b].pop()
	while(que[b] and que[b][0] < lv):
		que[b].popleft()
	ans -= len(que[b])

print(ans)
0