結果
| 問題 |
No.2353 Guardian Dogs in Spring
|
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2023-07-24 01:03:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 128 ms / 2,000 ms |
| コード長 | 737 bytes |
| コンパイル時間 | 362 ms |
| コンパイル使用メモリ | 82,336 KB |
| 実行使用メモリ | 79,524 KB |
| 最終ジャッジ日時 | 2024-09-25 03:55:09 |
| 合計ジャッジ時間 | 10,614 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 |
ソースコード
N = int(input())
Y = []
posi = []
for i in range(N):
x,y = map(int, input().split())
Y.append(y)
posi.append((i,x,y))
posi.sort(key=lambda x:x[1])
d = {num:i for i,num in enumerate(sorted(list(set(Y))))}
p = [list() for _ in range(N)]
for i,x,y in posi:
p[d[y]].append((i,x))
res = []
m = []
for i in range(len(p)):
if len(p[i])>=3:
cnt = len(p[i])//2
while cnt:
id1,_ = p[i].pop()
id2,_ = p[i].pop()
res.append((id1+1,id2+1))
cnt -= 1
while p[i]:
id,_ = p[i].pop()
m.append(id+1)
cnt = len(m)//2
while cnt:
id1 = m.pop()
id2 = m.pop()
res.append((id1,id2))
cnt -= 1
print(len(res))
for a,b in res:
print(a,b)
AEn