提交记录 13757
提交时间 |
评测时间 |
2020-08-06 13:51:20 |
2020-08-06 13:51:27 |
#include <bits/stdc++.h>
using namespace std;
unsigned solve(int n, char *s) {
int nsz = 1;
unsigned pool[266672] = {};
unsigned *dp = pool + 133336;
dp[0] = 1;
for (int i = 0; i < n; ++i) {
int sz = min(i + 1, n - i - 1) / 2 + 1;
if (s[i] == '(') {
if (i & 1) {
--dp;
dp[0] = 0;
}
} else if (s[i] == ')') {
if (~i & 1) {
++dp;
dp[sz] = 0;
}
} else {
if (i & 1) {
--dp;
dp[0] = 0;
int i;
for (i = 0; i + 1 < nsz; i += 2) {
dp[i] += dp[i + 1];
dp[i + 1] += dp[i + 2];
}
for (; i < nsz; ++i) {
dp[i] += dp[i + 1];
}
dp[sz] = 0;
} else {
int i;
for (i = 0; i + 1 < sz; i += 2) {
dp[i] += dp[i + 1];
dp[i + 1] += dp[i + 2];
}
for (; i < sz; ++i) {
dp[i] += dp[i + 1];
}
dp[sz] = 0;
}
}
nsz = sz;
}
return dp[0];
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 182.72 us | 1 MB + 44 KB | Accepted | Score: 25 | 显示更多 |
Testcase #2 | 574.301 ms | 1 MB + 160 KB | Accepted | Score: 25 | 显示更多 |
Testcase #3 | 2.033 s | 1 MB + 264 KB | Accepted | Score: 25 | 显示更多 |
Testcase #4 | 2.858 s | 1 MB + 304 KB | Accepted | Score: 25 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:35:02 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠