Submission #1773070
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long int LLI; const LLI MOD = 1e9+7; int N; int M; int C[258]; LLI dp[258][258][258]; LLI conv[258][258][258]; int main() { scanf("%d", &N); for (int i=0; i<N; i++) { scanf("%d", &C[i]); } if (C[0] != 1) { puts("0"); return 0; } for (int i=0; i<N; i++) { dp[i][i+1][0] = 1; conv[i][i+1][0] = dp[i][i+1][0]; for (int j=1; j<=N; j++) { conv[i][i+1][j] = (conv[i][i+1][j-1]+dp[i][i+1][j])%MOD; } } for (int w=2; w<=N; w++) { for (int l=0; l<N; l++) { int r = l+w; if (r > N) continue; for (int k=l+1; k<r; k++) { dp[l][r][C[k]] = (conv[l][k][C[k]-1]*conv[k][r][N])%MOD; } conv[l][r][0] = dp[l][r][0]; for (int k=1; k<=N; k++) { conv[l][r][k] = (conv[l][r][k-1]+dp[l][r][k])%MOD; } } } printf("%lld\n", conv[0][N][N]); }
Submission Info
Submission Time | |
---|---|
Task | G - スタンプラリー |
User | potetisensei |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 954 Byte |
Status | MLE |
Exec Time | 136 ms |
Memory | 268544 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:17:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &C[i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 2 ms | 2304 KB |
01-02.txt | AC | 3 ms | 10496 KB |
01-03.txt | AC | 12 ms | 53888 KB |
01-04.txt | MLE | 135 ms | 268544 KB |
01-05.txt | MLE | 136 ms | 268544 KB |
01-06.txt | MLE | 135 ms | 268544 KB |
01-07.txt | MLE | 135 ms | 268544 KB |
01-08.txt | AC | 1 ms | 256 KB |
01-09.txt | AC | 1 ms | 256 KB |
01-10.txt | MLE | 124 ms | 268544 KB |
01-11.txt | AC | 76 ms | 210816 KB |
01-12.txt | MLE | 127 ms | 268544 KB |
01-13.txt | AC | 88 ms | 225152 KB |
01-14.txt | MLE | 134 ms | 268544 KB |
01-15.txt | AC | 101 ms | 233472 KB |
01-16.txt | MLE | 131 ms | 268544 KB |
01-17.txt | MLE | 126 ms | 264448 KB |
01-18.txt | MLE | 122 ms | 268544 KB |
01-19.txt | MLE | 120 ms | 268544 KB |
01-20.txt | MLE | 122 ms | 268544 KB |
01-21.txt | AC | 102 ms | 245888 KB |
sample-01.txt | AC | 2 ms | 4352 KB |
sample-02.txt | AC | 1 ms | 256 KB |
sample-03.txt | AC | 7 ms | 31232 KB |