Submission #1655843
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = ll(1e9 + 7); ll F(int l, int r); ll T(int l, int r); int N; int C[300]; ll dpT[300][300]; ll dpF[300][300]; ll F(int l, int r){ ll& d = dpF[l][r]; if(d != -1) return d; int len = r - l; if(len == 1) return 1; d = 0; for(int i = l + 1; i < r; i++){ if(C[l] < C[i]){ d += T(l, i) * F(i, r); d %= MOD; } } d += T(l, r); d %= MOD; return d; } ll T(int l, int r){ ll& d = dpT[l][r]; if(d != -1) return d; int len = r - l; if(len == 1) return 1; return d = F(l + 1, r); } int main(){ cin.tie(0); ios::sync_with_stdio(false); #ifdef LOCAL std::ifstream in("in"); std::cin.rdbuf(in.rdbuf()); #endif cin >> N; for(int i = 0; i < N; i++){ cin >> C[i]; } memset(dpT, -1, sizeof dpT); memset(dpF, -1, sizeof dpF); if(C[0] != 1){ cout << 0 << endl; } else{ cout << T(0, N) << endl; } }
Submission Info
Submission Time | |
---|---|
Task | G - スタンプラリー |
User | femto16 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 969 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 1664 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 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 | 1664 KB |
01-02.txt | AC | 2 ms | 1664 KB |
01-03.txt | AC | 2 ms | 1664 KB |
01-04.txt | AC | 13 ms | 1664 KB |
01-05.txt | AC | 13 ms | 1664 KB |
01-06.txt | AC | 13 ms | 1664 KB |
01-07.txt | AC | 13 ms | 1664 KB |
01-08.txt | AC | 2 ms | 1664 KB |
01-09.txt | AC | 2 ms | 1664 KB |
01-10.txt | AC | 19 ms | 1664 KB |
01-11.txt | AC | 10 ms | 1664 KB |
01-12.txt | AC | 19 ms | 1664 KB |
01-13.txt | AC | 12 ms | 1664 KB |
01-14.txt | AC | 17 ms | 1664 KB |
01-15.txt | AC | 11 ms | 1664 KB |
01-16.txt | AC | 2 ms | 1664 KB |
01-17.txt | AC | 2 ms | 1664 KB |
01-18.txt | AC | 20 ms | 1664 KB |
01-19.txt | AC | 19 ms | 1664 KB |
01-20.txt | AC | 2 ms | 1664 KB |
01-21.txt | AC | 2 ms | 1664 KB |
sample-01.txt | AC | 2 ms | 1664 KB |
sample-02.txt | AC | 2 ms | 1664 KB |
sample-03.txt | AC | 2 ms | 1664 KB |