Submission #213320

# Submission time Handle Problem Language Result Execution time Memory
213320 2020-03-25T14:17:29 Z quocnguyen1012 Zapina (COCI20_zapina) C++14
55 / 110
151 ms 1912 KB
#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 305, mod = 1e9 + 7;

int f[maxn][maxn], C[maxn][maxn], N;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  for(int i = 0; i < maxn; ++i)
    C[0][i] = 1, C[i][i] = 1;
  for(int i = 1; i < maxn; ++i){
    for(int j = i + 1; j < maxn; ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i][j - 1]) % mod;
  }
  cin >> N;
  f[0][0] = 1;
  for(int i = 1; i <= N; ++i){
    for(int j = 0; j <= N; ++j){
      for(int k = 0; k <= j; ++k){
        if(k != i) f[i][j] = (f[i][j] + 1ll * C[k][N - j + k] * f[i - 1][j - k]) % mod;
      }
    }
  }
  ll res = 1;
  for(int i = 1; i <= N; ++i) res = res * N % mod;
  cout << (res - f[N][N] + mod) % mod;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 6 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 6 ms 768 KB Output is correct
17 Correct 87 ms 1016 KB Output is correct
18 Correct 6 ms 640 KB Output is correct
19 Correct 22 ms 896 KB Output is correct
20 Correct 5 ms 768 KB Output is correct
21 Correct 113 ms 1144 KB Output is correct
22 Correct 17 ms 896 KB Output is correct
23 Correct 6 ms 768 KB Output is correct
24 Correct 28 ms 896 KB Output is correct
25 Correct 21 ms 896 KB Output is correct
26 Correct 36 ms 1024 KB Output is correct
27 Runtime error 151 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Halted 0 ms 0 KB -