結果

問題 No.1254 補強への架け橋
ユーザー dot_haraaidot_haraai
提出日時 2021-06-05 20:35:51
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,843 bytes
コンパイル時間 4,553 ms
コンパイル使用メモリ 88,760 KB
実行使用メモリ 27,372 KB
最終ジャッジ日時 2024-11-21 19:24:34
合計ジャッジ時間 16,407 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 1 ms
6,820 KB
testcase_04 AC 1 ms
6,820 KB
testcase_05 AC 2 ms
6,816 KB
testcase_06 AC 1 ms
6,816 KB
testcase_07 AC 2 ms
6,816 KB
testcase_08 AC 2 ms
6,820 KB
testcase_09 AC 2 ms
6,816 KB
testcase_10 AC 2 ms
6,816 KB
testcase_11 AC 2 ms
6,820 KB
testcase_12 AC 1 ms
6,816 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
6,820 KB
testcase_17 AC 2 ms
6,820 KB
testcase_18 AC 1 ms
6,816 KB
testcase_19 WA -
testcase_20 AC 2 ms
6,816 KB
testcase_21 AC 1 ms
6,816 KB
testcase_22 AC 2 ms
6,820 KB
testcase_23 AC 2 ms
6,816 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
6,816 KB
testcase_27 WA -
testcase_28 AC 1 ms
6,820 KB
testcase_29 AC 2 ms
6,820 KB
testcase_30 AC 1 ms
6,820 KB
testcase_31 WA -
testcase_32 AC 2 ms
6,820 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
6,816 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
6,816 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 AC 4 ms
6,816 KB
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 WA -
testcase_104 WA -
testcase_105 WA -
testcase_106 WA -
testcase_107 WA -
testcase_108 WA -
testcase_109 WA -
testcase_110 WA -
testcase_111 WA -
testcase_112 WA -
testcase_113 WA -
testcase_114 WA -
testcase_115 WA -
testcase_116 WA -
testcase_117 WA -
testcase_118 WA -
testcase_119 WA -
testcase_120 WA -
testcase_121 WA -
testcase_122 WA -
testcase_123 AC 1 ms
6,816 KB
testcase_124 AC 143 ms
27,372 KB
testcase_125 AC 140 ms
26,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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]

ソースコード

diff #

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
    else:
      touch[p]=true
    for nIdx in 0..<es[p].len:
      var
        nxt = es[p][nIdx]
      if nxt == par:continue
      else:
        var t = dfs(p,nxt)
        if t:
          loopE[p][nIdx]=true
          loopE[nxt][invE[p][nIdx]]=true
        result = result or t


  if es.anyIt(it.len>=3):
    var
      s = 0
      t = 0
      ans = inithashset[int]()
    for i in 0..<n:
      if es[i].len>=3:
        s = i
    discard dfs(-1,s)
    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(" ")
    
    
    

  else:
    # 全部ループ
    var ans = newseq[int]()
    for i in 1..n:
      ans.add(i)
    echo n
    echo ans.join(" ")
      
     
solve()
0