結果

問題 No.1997 X Lighting
ユーザー Kiri8128Kiri8128
提出日時 2022-07-01 23:19:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 166,816 KB
最終ジャッジ日時 2023-08-17 11:03:26
合計ジャッジ時間 8,230 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 70 ms
71,040 KB
testcase_02 WA -
testcase_03 AC 72 ms
71,080 KB
testcase_04 AC 73 ms
71,088 KB
testcase_05 AC 102 ms
76,952 KB
testcase_06 AC 120 ms
77,356 KB
testcase_07 AC 73 ms
71,336 KB
testcase_08 AC 97 ms
76,980 KB
testcase_09 AC 97 ms
76,856 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 140 ms
77,440 KB
testcase_14 AC 221 ms
127,920 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
n = N - 1
pp = set()
mm = set()
ans = 0
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    p = x + y
    m = x - y
    if p not in pp:
        pp.add(p)
        ans += N - abs(p - n)
    if m not in mm:
        mm.add(m)
        ans += N - abs(m)

pp = sorted(pp)
mm = sorted(mm)
pp = sorted([n - abs(n - a) for a in pp])
mm = sorted([abs(a) for a in mm])
SS = sorted(set(pp + mm))
IA = {a: i for i, a in enumerate(SS)}
pp = [IA[a] for a in pp]
mm = [IA[a] for a in mm]
C = [0] * (len(SS) + 2)
for a in mm:
    C[a] += 1
for i in range(len(SS)):
    C[i+2] += C[i]

for a in pp:
    ans -= C[a]
print(ans)
0