結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
dgd1724
|
| 提出日時 | 2016-09-08 19:51:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 586 bytes |
| コンパイル時間 | 563 ms |
| コンパイル使用メモリ | 69,016 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 07:15:58 |
| 合計ジャッジ時間 | 1,335 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>
int main(void) {
//test用
//std::ifstream in("test.txt");
//std::cin.rdbuf(in.rdbuf());
int N, K;
std::cin >> N >> K;
std::string S;
std::cin >> S;
std::vector<std::size_t> pair(N);
while (S.find(")") <= N) {
std::size_t temp1,temp2;
temp1 = S.find(")");
temp2 = S.rfind("(", temp1);
pair[temp1] = temp2;
pair[temp2] = temp1;
S[temp1] = '0';
S[temp2] = '0';
}
std::cout << pair[K-1] + 1 << std::endl;
}
dgd1724