結果

問題 No.790 ちきんの括弧並べ
ユーザー 👑 ikd
提出日時 2019-02-20 22:24:33
言語 Nim
(2.2.10 + ACL)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 1,319 ms / 2,000 ms
+ 248µs
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,130 ms
コンパイル使用メモリ 67,932 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-08-03 11:39:11
合計ジャッジ時間 5,090 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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