Submission #334994

# Submission time Handle Problem Language Result Execution time Memory
334994 2020-12-10T17:12:47 Z achibasadzishvili Zapina (COCI20_zapina) C++14
110 / 110
259 ms 3180 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,C[500][500],dp[500][500],mod=1000000007;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    
    for(int i=0; i<=n; i++){
        C[i][0] = 1;
    }
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++){
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
        }
    dp[0][0] = 1;
    for(int i=1; i<=n; i++){
        dp[i][0] = 1;
        for(int j=1; j<=n; j++){
            for(int k=0; k<=j; k++){
                if(k != i){
                    dp[i][j] += dp[i - 1][j - k] * C[j][k];
                    dp[i][j] %= mod;
                }
            }
        }
    }
    ll ans = (mod - dp[n][n]),k = 1;
    for(int i=1; i<=n; i++){
        k *= n;
        k %= mod;
    }
    ans = (ans + k) % mod;
    cout << ans << '\n';
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 125 ms 2540 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 27 ms 1644 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 170 ms 2836 KB Output is correct
22 Correct 19 ms 1516 KB Output is correct
23 Correct 2 ms 876 KB Output is correct
24 Correct 35 ms 1772 KB Output is correct
25 Correct 24 ms 1644 KB Output is correct
26 Correct 48 ms 2028 KB Output is correct
27 Correct 238 ms 2952 KB Output is correct
28 Correct 240 ms 3052 KB Output is correct
29 Correct 243 ms 3080 KB Output is correct
30 Correct 243 ms 3052 KB Output is correct
31 Correct 246 ms 3180 KB Output is correct
32 Correct 247 ms 3052 KB Output is correct
33 Correct 248 ms 3052 KB Output is correct
34 Correct 255 ms 3052 KB Output is correct
35 Correct 255 ms 3052 KB Output is correct
36 Correct 255 ms 3052 KB Output is correct
37 Correct 259 ms 3180 KB Output is correct