結果

問題 No.592 括弧の対応 (2)
ユーザー aim_cpoaim_cpo
提出日時 2018-02-22 02:58:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 171,600 KB
実行使用メモリ 5,628 KB
最終ジャッジ日時 2023-10-21 23:11:59
合計ジャッジ時間 2,308 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 28 ms
5,420 KB
testcase_02 AC 26 ms
5,628 KB
testcase_03 AC 28 ms
5,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int n;
string s;
int a[200001];
int ans[200001];

int main(){
  cin>>n>>s;
  for(int i=0;i<n;i++)a[i]=i+1;
  stack<int> st;
  for(int i=0;i<n;i++){
    if(s[i]==')'){
      int temp=st.top();
      ans[i]=temp;
      ans[temp-1]=i+1;
      st.pop();
    }else{
      st.push(i+1);
    }
  }
  for(int i=0;i<n;i++)cout<<ans[i]<<"\n";
  return 0;
}
0