結果

問題 No.1997 X Lighting
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-07-01 22:51:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 796 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 131,944 KB
最終ジャッジ日時 2023-08-17 10:28:51
合計ジャッジ時間 13,268 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,088 KB
testcase_01 AC 72 ms
71,220 KB
testcase_02 AC 72 ms
71,224 KB
testcase_03 AC 72 ms
71,312 KB
testcase_04 AC 72 ms
71,112 KB
testcase_05 AC 109 ms
78,024 KB
testcase_06 AC 159 ms
87,744 KB
testcase_07 AC 77 ms
71,384 KB
testcase_08 AC 107 ms
77,948 KB
testcase_09 AC 102 ms
77,124 KB
testcase_10 AC 72 ms
71,408 KB
testcase_11 AC 76 ms
71,328 KB
testcase_12 AC 75 ms
71,320 KB
testcase_13 AC 194 ms
97,648 KB
testcase_14 AC 402 ms
131,944 KB
testcase_15 AC 275 ms
89,684 KB
testcase_16 AC 332 ms
95,784 KB
testcase_17 AC 652 ms
119,816 KB
testcase_18 AC 399 ms
100,748 KB
testcase_19 AC 764 ms
131,636 KB
testcase_20 AC 796 ms
122,104 KB
testcase_21 AC 785 ms
121,976 KB
testcase_22 AC 759 ms
131,716 KB
testcase_23 AC 435 ms
100,156 KB
testcase_24 AC 127 ms
78,324 KB
testcase_25 AC 777 ms
131,700 KB
testcase_26 AC 649 ms
120,060 KB
testcase_27 AC 664 ms
121,184 KB
testcase_28 AC 281 ms
88,132 KB
testcase_29 AC 283 ms
90,072 KB
testcase_30 AC 753 ms
130,732 KB
testcase_31 AC 526 ms
103,064 KB
testcase_32 AC 220 ms
83,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
XY = [list(map(int,input().split())) for i in range(m)]


S = [[[],[]] for i in range(2)]

for x,y in XY:
    d = (x+y)%2
    S[d][0].append(y-x)
    S[d][1].append(x+y)

ans = 0

for t in range(2):
    sp = set(S[t][0])
    sm = set(S[t][1])
    L = []
    for p in sp:
        ans += n-abs(p)
        L.append([abs(p)+2,1])
        L.append([2*n-abs(p)+1,-1])
    L.sort()
    sm = sorted(sm)
    count = 0
    now = 0
    for m in sm:
        while now < len(L) and L[now][0] <= m:
            count += L[now][1]
            now += 1

        base = n-abs(n+1-m)
        ans += base-count
print(ans)
0