結果

問題 No.592 括弧の対応 (2)
ユーザー ohreitetsuohreitetsu
提出日時 2017-11-12 17:11:09
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 516 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 60,208 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 10:57:42
合計ジャッジ時間 8,109 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	int sLen;
	cin>>sLen;
	cin>>s;
	vector<int> aw(sLen,0);
	int i=0;
	int LeftIndex=0;
	while (sLen>0){
		if (s[i]=='('){
			LeftIndex=i;
		}else if (s[i]==')'){
			aw[LeftIndex]=i;
			aw[i]=LeftIndex;
			s[LeftIndex]=' ';
			s[i]=' ';
			sLen-=2;
			while (LeftIndex>0 && s[LeftIndex]==' '){
				LeftIndex--;
			}
		}
		i++;
	}
	for (i=0;i<aw.size();i++){
		cout<<aw[i]+1<<endl;
	}
	return 0;
}
0