結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 16 ms
5,528 KB
testcase_34 AC 6 ms
4,912 KB
testcase_35 AC 10 ms
5,148 KB
testcase_36 AC 16 ms
5,500 KB
testcase_37 AC 6 ms
4,996 KB
testcase_38 AC 18 ms
5,584 KB
testcase_39 AC 7 ms
4,912 KB
testcase_40 AC 14 ms
5,276 KB
testcase_41 AC 15 ms
5,384 KB
testcase_42 AC 18 ms
5,564 KB
testcase_43 AC 20 ms
5,640 KB
testcase_44 AC 160 ms
10,356 KB
testcase_45 AC 158 ms
10,376 KB
testcase_46 AC 160 ms
10,368 KB
testcase_47 AC 159 ms
10,376 KB
testcase_48 AC 160 ms
10,456 KB
testcase_49 AC 19 ms
5,448 KB
testcase_50 AC 19 ms
5,412 KB
testcase_51 AC 19 ms
5,468 KB
testcase_52 AC 19 ms
5,512 KB
testcase_53 AC 160 ms
10,360 KB
testcase_54 AC 167 ms
10,364 KB
testcase_55 AC 161 ms
10,528 KB
testcase_56 AC 160 ms
10,448 KB
testcase_57 AC 160 ms
10,504 KB
testcase_58 AC 160 ms
10,364 KB
testcase_59 AC 160 ms
10,424 KB
testcase_60 AC 161 ms
10,396 KB
testcase_61 AC 159 ms
10,584 KB
testcase_62 AC 159 ms
10,560 KB
testcase_63 AC 306 ms
13,580 KB
testcase_64 AC 309 ms
13,584 KB
testcase_65 AC 151 ms
10,048 KB
testcase_66 AC 292 ms
12,648 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(23, 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)
  var dat = newSeqWith(n*2-1, -1)
  for i in 0..<m: dat[i+n-1] = if list[i].len>0: list[i].max else: -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
  this.dat[i] = if this.list[y].len>0: this.list[y].max else: -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