結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-16 22:12:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 957 bytes |
| コンパイル時間 | 791 ms |
| コンパイル使用メモリ | 71,616 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-30 01:08:52 |
| 合計ジャッジ時間 | 2,906 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 RE * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
s = s.substr(s.find('('));
s = s.substr(0, s.rfind(')') + 1);
int n = s.size();
vector<int> closes(n + 1 , 0);
for (int i = n - 1; i >= 0; i--) {
closes[i] = closes[i + 1];
if (s[i] == ')') {
closes[i]++;
}
}
const string sl = "(^^*)";
const string sr = "(*^^)";
int l_count = 0;
int r_count = 0;
for (int i = 0; i < n; i++) {
if (s[i] != '(') {
continue;
}
int l_idx = 1;
int r_idx = 1;
for (int j = i + 1; j < n; j++) {
if (l_idx <= 3 && s[j] == sl[l_idx]) {
l_idx++;
if (l_idx == 4) {
l_count += closes[j];
if (r_idx == 4) {
break;
}
}
}
if (r_idx <= 3 && s[j] == sr[r_idx]) {
r_idx++;
if (r_idx == 4) {
r_count += closes[j];
if (l_idx == 4) {
break;
}
}
}
}
}
cout << l_count << " " << r_count << endl;
return 0;
}