結果

問題 No.790 ちきんの括弧並べ
ユーザー ikd
提出日時 2019-02-20 22:24:33
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 1,178 ms / 2,000 ms
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,368 ms
コンパイル使用メモリ 67,296 KB
実行使用メモリ 7,712 KB
最終ジャッジ日時 2026-03-22 21:17:15
合計ジャッジ時間 4,367 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #
raw source code

import strutils, sequtils
proc main()=
  let n = stdin.readLine.parseInt * 2
  var ans = 0
  for bits in 0..<(1 shl n):
    var 
      cur = 0
      ok = true
    for i in 0..<n:
      if (bits and (1 shl i)) > 0:
        cur += 1
      else:
        cur -= 1
      if cur < 0:
        ok = false
        break
    if ok and (cur == 0):
      ans += 1
  echo ans
main()
0