結果
| 問題 |
No.592 括弧の対応 (2)
|
| コンテスト | |
| ユーザー |
kosakkun
|
| 提出日時 | 2017-11-10 22:24:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 5,000 ms |
| コード長 | 1,019 bytes |
| コンパイル時間 | 1,108 ms |
| コンパイル使用メモリ | 115,824 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 12:21:21 |
| 合計ジャッジ時間 | 2,395 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
int N;
string S;
int ans[200010];
int main() {
cin >> N >> S;
stack < int > sta;
REP(i,S.size()) {
if (S[i] == '(') {
sta.push(i + 1);
} else {
ans[sta.top()] = i + 1;
ans[i + 1] = sta.top();
sta.pop();
}
}
for (int i = 1; i <= N; i++) {
cout << ans[i] << endl;
}
return 0;
}
kosakkun