답안 #753010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753010 2023-06-04T12:49:12 Z Ronin13 Calvinball championship (CEOI15_teams) C++14
80 / 100
1000 ms 1280 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[nmax];
ll DP[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] = 1;
    DP[0] = 1;
    c[0] = 1;
    for(int i = 1; i <= n ;i++){
        for(int j = i; j >= 1 ;j--){
            dp[j] = (ll)dp[j - 1] + (ll)dp[j] * (ll)j;
            DP[i] += dp[j];
            DP[i] %= mod;
            dp[j] %= mod;
        }
        dp[0] = 0;
       // cout << DP[i] << ' ';
    }
    set <int> st;
    ll po[n + 1];
    ll ans = 1;
    int val[n + 1];
    val[1] = 1;
    st.insert(a[1]);
    for(int i = 2; i <= n; i++){
        st.insert(a[i]);
        val[i] = st.size();
    }
    for(int i = n ;i >= 2; --i){
        c[n - i] = 1;
        for(int j = n - i - 1; j >= 1 ;j--)
            c[j] += c[j - 1], c[j] %= mod;
        if(i != 1){
            po[0] = 1;
            ll k= val[i - 1];
            for(int j = 1; j <= n - i; 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;
        }

    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 224 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 344 KB Output is correct
2 Correct 19 ms 352 KB Output is correct
3 Correct 18 ms 412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 1280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 406 ms 508 KB Output is correct
2 Correct 406 ms 520 KB Output is correct
3 Correct 419 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 892 KB Time limit exceeded
2 Halted 0 ms 0 KB -