結果

問題 No.488 四角関係
ユーザー むらためむらため
提出日時 2019-01-18 18:14:58
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,275 bytes
コンパイル時間 843 ms
コンパイル使用メモリ 74,388 KB
最終ジャッジ日時 2024-04-27 02:46:31
合計ジャッジ時間 1,259 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 28) Error: cannot open file: queues

ソースコード

diff #

import sequtils,strutils,algorithm,math,sugar,macros,strformat
import sets,tables,intsets,queues,heapqueue,bitops
template get*():string = stdin.readLine().strip()
macro unpack*(arr: auto,cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `arr`;())
  for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
template times*(n:int,body) = (for _ in 0..<n: body)
proc toCountSeq[T](x:seq[T]) : seq[tuple[k:T,v:int]] = toSeq(x.toCountTable().pairs)
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord

let n = scan() # 50
let m = scan() # 1000
let AB = newSeqWith(m,(scan(),scan()))
var mat = newSeqWith(n,newSeq[bool](n))
for ab in AB:
  let (a,b) = ab
  mat[a][b] = true
  mat[b][a] = true
var ans = 0
for i in 0..<m:
  let (a,b) = AB[i]
  for j in (i+1)..<m:
    let (c,d) = AB[j]
    if a == c or a == d or b == c or b == d: continue
    if mat[a][c] and mat[b][d] and not mat[a][d] and not mat[b][c] : ans += 1
    elif not mat[a][c] and not mat[b][d] and mat[a][d] and mat[b][c] : ans += 1
echo ans div 2
0