Submission #32734

# Submission time Handle Problem Language Result Execution time Memory
32734 2017-10-14T15:06:42 Z imaxblue Calvinball championship (CEOI15_teams) C++14
0 / 100
3 ms 2328 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, a[10005], b[10005], ans=1;
vector<int> dp[10001];
void dfs(int N, int T){
    //if (T>1001) return;
    if (T>b[N]) return;
    if (dp[N][T]!=0) return;
    while (dp[N].size()<=T) dp[N].pb(0);
    if (N==n){
        dp[N][T]=1;
        return;
    }
    dfs(N+1, T);
    dfs(N+1, T+1);
    dp[N][T]+=(1LL*T*dp[N+1][T])%MN;
    dp[N][T]+=dp[N+1][T+1];
    dp[N][T]%=MN;
}
void dfs2(int N, int T){
    if (N==n) return;
    dfs(N+1, T);
    ans=(1LL*dp[N+1][T]*(a[N]-1)+ans)%MN;
    dfs2(N+1, max(a[N], T));
}
int main(){
    cin >> n;
    //fox(l, n+1) dp[l]=vector<int>(l+1, 0);
    fox(l, n){
        cin >> a[l];
    }
    fox1(l, n) b[l]=max(b[l-1], a[l]);
    dfs2(0, 0);
    cout << ans;
    return 0;
}

Compilation message

teams.cpp: In function 'void dfs(int, int)':
teams.cpp:33:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (dp[N].size()<=T) dp[N].pb(0);
                        ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -