結果
問題 |
No.592 括弧の対応 (2)
|
ユーザー |
![]() |
提出日時 | 2017-11-11 15:32:52 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 58 ms / 5,000 ms |
コード長 | 540 bytes |
コンパイル時間 | 1,579 ms |
コンパイル使用メモリ | 147,404 KB |
実行使用メモリ | 9,448 KB |
最終ジャッジ日時 | 2024-06-12 22:29:30 |
合計ジャッジ時間 | 2,300 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
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)); } }