結果
| 問題 | No.1254 補強への架け橋 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-06-05 20:16:13 | 
| 言語 | Nim (2.2.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,608 bytes | 
| コンパイル時間 | 6,196 ms | 
| コンパイル使用メモリ | 88,704 KB | 
| 実行使用メモリ | 38,912 KB | 
| 最終ジャッジ日時 | 2024-11-21 19:02:58 | 
| 合計ジャッジ時間 | 21,339 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 WA * 108 | 
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 18) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'times' [UnusedImport] /home/judge/data/code/Main.nim(2, 26) Warning: imported and not used: 'strformat' [UnusedImport] /home/judge/data/code/Main.nim(2, 18) Warning: imported and not used: 'future' [UnusedImport] /home/judge/data/code/Main.nim(2, 37) Warning: imported and not used: 'deques' [UnusedImport] /home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 52) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'critbits' [UnusedImport] /home/judge/data/code/Main.nim(1, 66) Warning: imported and not used: 'lists' [UnusedImport] /home/judge/data/code/Main.nim(1, 73) Warning: imported and not used: 'intsets' [UnusedImport]
ソースコード
import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets
import critbits, future, strformat, deques
template `max=`(x,y) = x = max(x,y)
template `min=`(x,y) = x = min(x,y)
template `mod=`(x,y) = x = x mod y
template scan2 = (scan(), scan())
template scan3 = (scan(), scan())
let read* = iterator: string {.closure.} =
    while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
proc scanf(): float = read().parseFloat
proc toInt(c:char): int =
    return int(c) - int('0')
proc solve()=
  var
    n = scan()
    es = newseqwith(n,newseq[int]())
    
    loopE = newseqwith(n,newseq[bool]())
    invE = newseqwith(n,newseq[int]())
    ids = newseqwith(n,newseq[int]())
    touch = newseqwith(n,false)
  for i in 0..<n:
    var
      a = scan()-1
      b = scan()-1
    es[a].add(b)
    loopE[a].add(false)
    ids[a].add(i+1)
    es[b].add(a)
    loopE[b].add(false)
    ids[b].add(i+1)
    invE[a].add(es[b].len-1)
    invE[b].add(es[a].len-1)
  proc dfs(par:int,p:int):bool=
    if touch[p]:
      return true
    touch[p]=true
    for nIdx in 0..<es[p].len:
      var nxt = es[p][nIdx]
      if nxt == par:continue
      else:
        if dfs(p,nxt):
          loopE[p][nIdx]=true
          loopE[nxt][invE[p][nIdx]]=true
          result = result or true
  discard dfs(-1,0)
  #echo es.join("\n")
  #echo ids.join("\n")
  #echo loopE.join("\n")
  var ans = inithashset[int]()
  for p in 0..<n:
    for nIdx in 0..<es[p].len:
      if loopE[p][nIdx]:
        ans.incl(ids[p][nIdx])
  echo ans.len
  echo ans.toseq.join(" ")
  
      
     
solve()
            
            
            
        