結果

問題 No.592 括弧の対応 (2)
ユーザー mkanmkan
提出日時 2017-11-10 22:46:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 261 ms / 5,000 ms
コード長 1,105 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 77,044 KB
実行使用メモリ 4,552 KB
最終ジャッジ日時 2023-08-16 03:25:47
合計ジャッジ時間 2,156 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 259 ms
4,388 KB
testcase_02 AC 257 ms
4,552 KB
testcase_03 AC 261 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,ans[200005]={0};
  string s;
  stack<int> left,right;
  cin>>n>>s;
  rep(i,n){
    if(s[i]=='('){
      left.push(i+1);
    }else{
      ans[left.top()]=i+1;
      ans[i+1]=left.top();
      left.pop();
    }
  }
  REP(i,1,n+1)cout<<ans[i]<<endl;
  return 0;
}
0