Submission #1624467


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)

bool check(string s) {
	if (s.front() == '(' && s.back() == ')');
	else return false;
	s.erase(s.begin());
	s.erase(s.end() - 1);
	int x = 0;
	bool ok = false;
	for (char c: s) {
		if (c == '(') x++;
		if (c == ')') x--;
		if (c == '*') ok = true;
		if (x < 0) return false;
	}
	return !x && ok;
}

int main() {
	string s; cin >> s;
	int N = s.length(), ans = 0;
	for (int l = 0; l <= N; l++)
		for (int r = l + 1; r <= N; r++)
			if (check(s.substr(l, r - l)))
				ans++;
	cout << ans << endl;
}

Submission Info

Submission Time
Task A - Star in Parentheses
User zenkan_rta
Language C++14 (GCC 5.4.1)
Score 100
Code Size 621 Byte
Status AC
Exec Time 2 ms
Memory 256 KiB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 29
Set Name Test Cases
All 00_sample_00, 00_sample_01, 00_sample_02, 00_sample_03, 00_sample_04, 00_sample_05, 10_rand_00, 10_rand_01, 10_rand_02, 10_rand_03, 10_rand_04, 10_rand_05, 10_rand_06, 10_rand_07, 10_rand_08, 10_rand_09, 11_rand_00, 11_rand_01, 11_rand_02, 11_rand_03, 11_rand_04, 11_rand_05, 11_rand_06, 11_rand_07, 11_rand_08, 11_rand_09, 90_challenge_00, 90_challenge_01, 90_challenge_02
Case Name Status Exec Time Memory
00_sample_00 AC 1 ms 256 KiB
00_sample_01 AC 1 ms 256 KiB
00_sample_02 AC 1 ms 256 KiB
00_sample_03 AC 1 ms 256 KiB
00_sample_04 AC 1 ms 256 KiB
00_sample_05 AC 1 ms 256 KiB
10_rand_00 AC 1 ms 256 KiB
10_rand_01 AC 1 ms 256 KiB
10_rand_02 AC 1 ms 256 KiB
10_rand_03 AC 1 ms 256 KiB
10_rand_04 AC 1 ms 256 KiB
10_rand_05 AC 1 ms 256 KiB
10_rand_06 AC 1 ms 256 KiB
10_rand_07 AC 1 ms 256 KiB
10_rand_08 AC 1 ms 256 KiB
10_rand_09 AC 1 ms 256 KiB
11_rand_00 AC 2 ms 256 KiB
11_rand_01 AC 2 ms 256 KiB
11_rand_02 AC 2 ms 256 KiB
11_rand_03 AC 2 ms 256 KiB
11_rand_04 AC 2 ms 256 KiB
11_rand_05 AC 2 ms 256 KiB
11_rand_06 AC 2 ms 256 KiB
11_rand_07 AC 2 ms 256 KiB
11_rand_08 AC 2 ms 256 KiB
11_rand_09 AC 2 ms 256 KiB
90_challenge_00 AC 1 ms 256 KiB
90_challenge_01 AC 2 ms 256 KiB
90_challenge_02 AC 1 ms 256 KiB