結果

問題 No.1997 X Lighting
ユーザー googol_S0googol_S0
提出日時 2022-07-01 21:48:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 143,616 KB
最終ジャッジ日時 2024-05-04 16:11:36
合計ジャッジ時間 5,816 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,096 KB
testcase_01 AC 37 ms
52,224 KB
testcase_02 AC 37 ms
51,968 KB
testcase_03 AC 34 ms
51,968 KB
testcase_04 AC 34 ms
52,224 KB
testcase_05 AC 73 ms
76,928 KB
testcase_06 AC 122 ms
86,784 KB
testcase_07 AC 38 ms
53,248 KB
testcase_08 AC 73 ms
76,800 KB
testcase_09 AC 73 ms
71,552 KB
testcase_10 AC 37 ms
52,608 KB
testcase_11 AC 39 ms
53,248 KB
testcase_12 AC 39 ms
52,608 KB
testcase_13 AC 157 ms
99,200 KB
testcase_14 AC 191 ms
140,796 KB
testcase_15 AC 132 ms
88,320 KB
testcase_16 AC 160 ms
89,472 KB
testcase_17 AC 209 ms
130,816 KB
testcase_18 AC 154 ms
105,684 KB
testcase_19 AC 230 ms
142,848 KB
testcase_20 AC 245 ms
137,128 KB
testcase_21 AC 244 ms
137,216 KB
testcase_22 AC 234 ms
142,720 KB
testcase_23 AC 161 ms
105,472 KB
testcase_24 AC 81 ms
77,180 KB
testcase_25 AC 245 ms
142,464 KB
testcase_26 AC 207 ms
129,280 KB
testcase_27 AC 213 ms
129,280 KB
testcase_28 AC 122 ms
89,600 KB
testcase_29 AC 134 ms
88,320 KB
testcase_30 AC 231 ms
143,616 KB
testcase_31 AC 178 ms
116,060 KB
testcase_32 AC 106 ms
82,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
X=[list(map(int,input().split())) for i in range(M)]
A=[]
B=[]
for i in range(M):
  A.append(X[i][0]+X[i][1]-N-1)
  B.append(X[i][0]-X[i][1])
A=sorted(set(A))
B=sorted(set(B))
def f(X,Y):
  for i in range(len(X)):
    X[i]=abs(X[i])
  for i in range(len(Y)):
    Y[i]=abs(Y[i])
  X=sorted(X)
  Y=sorted(Y)
  ANS=0
  v=len(Y)
  for i in range(len(X)):
    while v!=0:
      if X[i]+Y[v-1]>=N:
        v-=1
      else:
        break
    ANS+=v
  return ANS

C=[[],[]]
D=[[],[]]
ANS=0
for i in range(len(A)):
  C[A[i]&1].append(A[i])
  ANS+=N-abs(A[i])
for i in range(len(B)):
  D[B[i]&1].append(B[i])
  ANS+=N-abs(B[i])
if N&1:
  D[0],D[1]=D[1][:],D[0][:]
print(ANS-(f(C[0],D[1])+f(C[1],D[0])))
0