結果

問題 No.759 悪くない忘年会にしような!
ユーザー ikdikd
提出日時 2018-12-07 17:42:38
言語 Nim
(2.0.2)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 1,794 bytes
コンパイル時間 3,563 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2023-09-13 21:20:01
合計ジャッジ時間 10,886 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 16 ms
5,340 KB
testcase_34 AC 6 ms
4,928 KB
testcase_35 AC 10 ms
5,296 KB
testcase_36 AC 16 ms
5,292 KB
testcase_37 AC 6 ms
4,960 KB
testcase_38 AC 18 ms
5,376 KB
testcase_39 AC 7 ms
4,992 KB
testcase_40 AC 14 ms
5,252 KB
testcase_41 AC 15 ms
5,492 KB
testcase_42 AC 18 ms
5,408 KB
testcase_43 AC 19 ms
5,528 KB
testcase_44 AC 159 ms
10,580 KB
testcase_45 AC 159 ms
10,548 KB
testcase_46 AC 159 ms
10,604 KB
testcase_47 AC 159 ms
10,420 KB
testcase_48 AC 160 ms
10,448 KB
testcase_49 AC 19 ms
5,472 KB
testcase_50 AC 19 ms
5,412 KB
testcase_51 AC 19 ms
5,512 KB
testcase_52 AC 19 ms
5,412 KB
testcase_53 AC 162 ms
10,368 KB
testcase_54 AC 160 ms
10,432 KB
testcase_55 AC 159 ms
10,492 KB
testcase_56 AC 159 ms
10,368 KB
testcase_57 AC 160 ms
10,400 KB
testcase_58 AC 162 ms
10,320 KB
testcase_59 AC 159 ms
10,348 KB
testcase_60 AC 159 ms
10,492 KB
testcase_61 AC 158 ms
10,460 KB
testcase_62 AC 160 ms
10,372 KB
testcase_63 AC 305 ms
13,440 KB
testcase_64 AC 306 ms
13,376 KB
testcase_65 AC 151 ms
9,996 KB
testcase_66 AC 290 ms
12,804 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(28, 16) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated]

ソースコード

diff #

import strutils, sequtils, algorithm

type P = tuple[x: int, y: int, z: int, idx: int]
type SegmentTree = object
  n: int
  dat: seq[int]
  list: seq[seq[int]]
proc init(pts: seq[P]): SegmentTree =
  var m = 1
  for pt in pts: m = max(m, pt.y+1)
  var n = 1
  while n<m: n*=2
  var list = newSeqWith(n, newSeq[int](0))
  for pt in pts: list[pt.y].add(pt.z)
  # for i in 0..<list.len: list[i].sort(proc(a, b:int):int=cmp(a, b))
  var dat = newSeqWith(n*2-1, -1)
  for i in 0..<m:
    if list[i].len>0:
      dat[i+n-1] = list[i].max
    else:
      dat[i+n-1] = -1
  var i = n-2
  while i>=0:
    dat[i] = max(dat[i*2+1], dat[i*2+2])
    i-=1
  result = SegmentTree(n: n, dat: dat, list: list) # ......
proc del(this: var SegmentTree, y: int) =
  this.list[y].delete(0, 0)
  var i = y+this.n-1
  if this.list[y].len>0:
    this.dat[i] = this.list[y].max
  else:
    this.dat[i] = -1
  while i>0:
    i = (i-1) div 2
    this.dat[i] = max(this.dat[i*2+1], this.dat[i*2+2])
proc maxz(this: SegmentTree, ql, qr, i, il, ir: int): int =
  if qr<=il or ir<=ql:
    result = -1
  elif ql<=il and ir<=qr:
    result = this.dat[i]
  else:
    let m = (il+ir) div 2
    result = max(this.maxz(ql, qr, i*2+1, il, m), this.maxz(ql, qr, i*2+2, m,
        ir))

let n = stdin.readLine.parseInt
var
  pts = newSeq[P](n)
  ymax = 0
for i in 0..<n:
  (pts[i].x, pts[i].y, pts[i].z) = stdin.readLine.split.map(parseInt)
  pts[i].idx = i
  ymax = max(ymax, pts[i].y)
pts.sort do (p, q: P) -> int:
  result = cmp(p.x, q.x)
  if result==0:
    result = cmp(p.y, q.y)
    if result==0:
      result = cmp(p.z, q.z)
var
  tree = init(pts)
  ans = newSeq[int]()
for pt in pts:
  tree.del(pt.y)
  let z = tree.maxz(pt.y, ymax+1, 0, 0, tree.n)
  if pt.z>z:
    ans.add(pt.idx)
ans.sort(system.cmp)
for a in ans: echo a+1
0