結果
| 問題 |
No.1997 X Lighting
|
| コンテスト | |
| ユーザー |
Kiri8128
|
| 提出日時 | 2022-07-01 23:19:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 669 bytes |
| コンパイル時間 | 313 ms |
| コンパイル使用メモリ | 81,852 KB |
| 実行使用メモリ | 165,720 KB |
| 最終ジャッジ日時 | 2024-11-26 07:16:02 |
| 合計ジャッジ時間 | 6,421 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 9 WA * 21 |
ソースコード
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)
Kiri8128