結果
| 問題 |
No.592 括弧の対応 (2)
|
| コンテスト | |
| ユーザー |
aim_cpo
|
| 提出日時 | 2018-02-22 02:58:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 5,000 ms |
| コード長 | 392 bytes |
| コンパイル時間 | 1,636 ms |
| コンパイル使用メモリ | 171,296 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 00:40:53 |
| 合計ジャッジ時間 | 2,586 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#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;
}
aim_cpo