結果

問題 No.592 括弧の対応 (2)
ユーザー te-shte-sh
提出日時 2017-11-10 22:43:05
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 369 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 83,540 KB
実行使用メモリ 5,056 KB
最終ジャッジ日時 2023-09-03 16:47:38
合計ジャッジ時間 1,640 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 59 ms
4,532 KB
testcase_02 AC 56 ms
4,620 KB
testcase_03 AC 57 ms
5,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(9): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp;

  auto a = 0, d = new int[](n), e = new int[](n);
  foreach (int i, c; s) {
    if (c == '(') {
      ++a;
      e[a] = i;
    } else {
      d[i] = e[a];
      d[e[a]] = i;
      --a;
    }
  }
  foreach (di; d) writeln(di+1);
}
0