結果

問題 No.709 優勝可能性
ユーザー ikd
提出日時 2018-07-15 15:22:59
言語 Nim
(2.2.0)
結果
AC  
実行時間 368 ms / 3,500 ms
コード長 615 bytes
コンパイル時間 4,629 ms
コンパイル使用メモリ 65,828 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-07-01 03:11:15
合計ジャッジ時間 8,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils
var 
  args=stdin.readLine.split.map(parseInt)
  (n, m)=(args[0], args[1])

var
  deg=newSeq[int](n)
  stack=newSeqWith(m, newSeq[int]())
  top=newSeq[int](m)
  cnt=0

for i in 0..<n:
  var
    params=stdin.readLine.split.map(parseInt)
    ad=false
  for j, val in params:
    if top[j]<val:
      while stack[j].len>0:
        var k=stack[j].pop
        deg[k]-=1
        if deg[k]==0:
          cnt-=1
      stack[j].add(i)
      deg[i]+=1
      top[j]=val
      ad=true
    elif top[j]==val:
      stack[j].add(i)
      deg[i]+=1
      ad=true
    # else:
  if ad:
    cnt+=1
  echo cnt
0