結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
|
提出日時 | 2017-11-10 22:23:21 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 458 ms / 5,000 ms |
コード長 | 534 bytes |
コンパイル時間 | 672 ms |
コンパイル使用メモリ | 115,488 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 22:22:43 |
合計ジャッジ時間 | 2,217 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop;void main() {auto N = readln.chomp.to!int;auto S = readln.chomp;auto ans = new int[](N);int[] stack;foreach (i; 0..N) {if (S[i] == '(')stack ~= i;else {ans[i] = stack.back + 1;ans[stack.back] = i + 1;stack.popBack;}}ans.each!writeln;}