結果

問題 No.1997 X Lighting
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-07-01 22:51:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 622 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 130,708 KB
最終ジャッジ日時 2024-05-04 17:16:28
合計ジャッジ時間 10,175 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
51,968 KB
testcase_01 AC 34 ms
52,224 KB
testcase_02 AC 36 ms
52,224 KB
testcase_03 AC 33 ms
52,352 KB
testcase_04 AC 35 ms
51,840 KB
testcase_05 AC 68 ms
76,800 KB
testcase_06 AC 106 ms
85,376 KB
testcase_07 AC 37 ms
53,248 KB
testcase_08 AC 68 ms
76,800 KB
testcase_09 AC 62 ms
71,936 KB
testcase_10 AC 34 ms
52,736 KB
testcase_11 AC 36 ms
53,248 KB
testcase_12 AC 34 ms
52,096 KB
testcase_13 AC 134 ms
96,896 KB
testcase_14 AC 310 ms
130,280 KB
testcase_15 AC 204 ms
88,864 KB
testcase_16 AC 254 ms
94,208 KB
testcase_17 AC 513 ms
119,264 KB
testcase_18 AC 309 ms
99,968 KB
testcase_19 AC 604 ms
129,816 KB
testcase_20 AC 615 ms
125,948 KB
testcase_21 AC 618 ms
124,520 KB
testcase_22 AC 597 ms
130,532 KB
testcase_23 AC 335 ms
102,016 KB
testcase_24 AC 84 ms
77,372 KB
testcase_25 AC 617 ms
130,708 KB
testcase_26 AC 517 ms
119,572 KB
testcase_27 AC 522 ms
120,336 KB
testcase_28 AC 212 ms
89,600 KB
testcase_29 AC 222 ms
88,960 KB
testcase_30 AC 622 ms
129,416 KB
testcase_31 AC 409 ms
106,876 KB
testcase_32 AC 168 ms
83,328 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