結果

問題 No.22 括弧の対応
ユーザー compass1201
提出日時 2018-06-29 21:17:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 61,788 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 23:54:20
合計ジャッジ時間 1,292 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>

using namespace std;

int main()
{
	int num;
	int aim;
	int i = 0;
	int tmp;
	char c;
	vector<int> start;
	vector<int> end;
	string s;
	cin >> num >> aim;
	cin >> s;

	while (num > i)
	{
		c = s[i];
		if (c == '(')
			start.push_back(i);
		if (c == ')')
			end.push_back(i);
		i++;
	}
	i = 0;
	while (1)
	{
		if (aim-1 == start[i])
		{
			cout << end[num / 2 - i];
			break;
		}
		if (aim-1 == end[i])
		{
			cout << start[num / 2 - i];
			break;
		}
		i++;
	}


	return 0;
}
0