結果

問題 No.592 括弧の対応 (2)
ユーザー ikdikd
提出日時 2017-11-11 15:32:52
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 145,652 KB
実行使用メモリ 9,364 KB
最終ジャッジ日時 2023-09-03 16:51:31
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 64 ms
9,364 KB
testcase_02 AC 63 ms
9,344 KB
testcase_03 AC 61 ms
7,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.container;

  int n; rd(n);
  auto s=readln.chomp.to!(char[]);

  auto pos=new size_t[](n);
  auto lis=new DList!(size_t);
  foreach(i, c; s){
    if(c=='(') lis.insertFront(i);
    else pos[i]=lis.front+1, pos[lis.front]=i+1, lis.removeFront;
  }

  writefln("%(%d\n%)", pos);
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
0