結果

問題 No.22 括弧の対応
ユーザー kou_kkkkou_kkk
提出日時 2024-03-29 02:09:44
言語 Nim
(2.0.2)
結果
AC  
実行時間 167 ms / 5,000 ms
コード長 321 bytes
コンパイル時間 3,271 ms
コンパイル使用メモリ 65,732 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-29 02:09:54
合計ジャッジ時間 5,765 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 167 ms
6,548 KB
testcase_04 AC 33 ms
6,548 KB
testcase_05 AC 31 ms
6,548 KB
testcase_06 AC 71 ms
6,548 KB
testcase_07 AC 107 ms
6,548 KB
testcase_08 AC 53 ms
6,548 KB
testcase_09 AC 41 ms
6,548 KB
testcase_10 AC 97 ms
6,548 KB
testcase_11 AC 29 ms
6,548 KB
testcase_12 AC 57 ms
6,548 KB
testcase_13 AC 101 ms
6,548 KB
testcase_14 AC 4 ms
6,548 KB
testcase_15 AC 141 ms
6,548 KB
testcase_16 AC 144 ms
6,548 KB
testcase_17 AC 1 ms
6,548 KB
testcase_18 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(21, 5) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated]

ソースコード

diff #

import sequtils, strutils

let
  nk = stdin.readLine.split.map parseInt
  n = nk[0]
  k = nk[1]
  s = readLine stdin
var
  a = (1..n).toSeq
  b = s
  c = (-1).repeat n

while b.len > 0:
  let
    i = b.find "()"
    j = i.succ
  
  c[a[i].pred] = a[j]
  c[a[j].pred] = a[i]
  a.delete i..j
  b.delete i, j

echo c[k.pred]
0