結果

問題 No.592 括弧の対応 (2)
ユーザー beetbeet
提出日時 2017-11-10 22:32:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 253 ms / 5,000 ms
コード長 343 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 148,280 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-08-16 03:12:10
合計ジャッジ時間 2,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 253 ms
4,380 KB
testcase_02 AC 239 ms
4,476 KB
testcase_03 AC 243 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  string s;
  cin>>n>>s;
  stack<int> t;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    if(s[i]=='(') t.push(i);
    else{
      int k=t.top();t.pop();
      a[k]=i;
      a[i]=k;
    }
  }
  for(int i=0;i<n;i++) cout<<a[i]+1<<endl;
  
  return 0;
}
0