結果
問題 | No.592 括弧の対応 (2) |
ユーザー | aaaaa |
提出日時 | 2017-11-10 22:36:28 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 24 ms / 5,000 ms |
コード長 | 754 bytes |
コンパイル時間 | 950 ms |
コンパイル使用メモリ | 74,552 KB |
実行使用メモリ | 4,448 KB |
最終ジャッジ日時 | 2023-08-16 03:16:05 |
合計ジャッジ時間 | 1,357 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 24 ms
4,380 KB |
testcase_02 | AC | 23 ms
4,448 KB |
testcase_03 | AC | 23 ms
4,376 KB |
ソースコード
#include <iostream> #include <stdio.h> #include <cstring> #include <math.h> #include <algorithm> #include <vector> #include <string> #include <stdlib.h> #include <queue> #include <stack> #include <utility> #include <fstream> #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define FOR(i,a,b) for(int i=a;i<b;i++) #define ll long long #define INF 1000000001 #define mod 1000000007 #define p pair<int,int> int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; using namespace std; int main(){ int n; cin>>n; string s; cin>>s; vector<int> ans(n); stack<int> sta; rep(i,n){ if(s[i]=='('){ sta.push(i); }else{ int x=sta.top(); sta.pop(); ans[x]=i; ans[i]=x; } } rep(i,n){ printf("%d\n",ans[i]+1); } }