# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19837 |
2016-02-25T06:09:22 Z |
yukariko |
괄호 (kriii4_R) |
C++14 |
|
7 ms |
19300 KB |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int N, M;
long long cache[2000001];
char res[2000001];
long long solve(int pos)
{
if(pos > 2 * N)
return 0;
if(pos == 2 * N)
{
puts(res);
return 1;
}
long long& ans = cache[pos];
//if(ans != -1)
// return ans;
res[pos / 2] = '(';
res[2 * N - (pos / 2) - 1] = ')';
ans = (solve(pos + 2) * M) % MOD;
res[pos / 2 + 1] = ')';
res[2 * N - (pos / 2) - 2] = '(';
ans = (ans + solve(pos + 4) * M) % MOD;
return ans;
}
int main()
{
memset(cache, -1, sizeof(cache));
scanf("%d%d", &N, &M);
cache[0] = M;
cache[1] = M;
for(int i=2; i <= N; i++)
cache[i] = (cache[i-1] * 2 + cache[i-2] * 4 * (i - 1)) / (i + 1);
printf("%lld\n", cache[N]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
19300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |