답안 #753006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753006 2023-06-04T12:39:01 Z Ronin13 Calvinball championship (CEOI15_teams) C++14
0 / 100
1000 ms 788 KB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
#define pii pair<int,int>
using namespace std;
const int nmax = 10001;
ll mod = 1e6 + 7;

ll dp[2][nmax];
ll DP[nmax];
ll f[nmax];
ll inv[nmax];
ll c[nmax];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    //fil(2);
    int a[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0][0] = 1;
    DP[0] = 1;
    c[0] = 1;
    for(int i = 1; i <= n ;i++){
        for(int j = 1; j <= i ;j++){
            dp[1][j] = dp[0][j - 1] + dp[0][j] * (ll)j;
            dp[1][j] %= mod;
        }
        for(int j = 0; j <= n; j++){
            dp[0][j] = dp[1][j];
            DP[i] += dp[0][j];
            DP[i] %= mod;
            dp[1][j] = 0;
        }
       // cout << DP[i] << ' ';
    }
    set <int> st;
    ll po[n + 1];
    ll ans = 1;
    for(int i = 1 ;i <= n; ++i){
        c[i] = 1;
        for(int j = i - 1; j >= 1 ;j--)
            c[j] += c[j - 1], c[j] %= mod;
        if(i != 1){
            po[0] = 1;
            ll k= st.size();
            for(int j = 1; j <= n; j++)
                po[j] = po[j - 1] * k % mod;
            ll res = 0;
            for(int x = 0; x <= n - i; x++){
                res += c[x] * DP[x] * po[n - i - x];
                res %= mod;
            }
            res *= (ll)(a[i] - 1);
            res %= mod;
            ans += res;
            ans %= mod;
        }
        st.insert(a[i]);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1076 ms 764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 491 ms 524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 788 KB Time limit exceeded
2 Halted 0 ms 0 KB -