結果

問題 No.592 括弧の対応 (2)
ユーザー LapinponLapinpon
提出日時 2017-11-10 22:38:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 250 ms / 5,000 ms
コード長 349 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 61,528 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 12:52:27
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <stack>
using namespace	std;
int main(){

  int n,a[200000];
  string s;
  stack <int> b;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='('){
      b.push(i);
    } else {
      a[i]=b.top();
      a[b.top()]=i;
      b.pop();
    }
  }
  for(int i=0;i<n;i++) cout<<a[i]+1<<endl;
  return 0;

}



0