Submission #213321

# Submission time Handle Problem Language Result Execution time Memory
213321 2020-03-25T14:18:02 Z quocnguyen1012 Zapina (COCI20_zapina) C++14
110 / 110
173 ms 1400 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 = 355, 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 640 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 5 ms 896 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 5 ms 896 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 6 ms 1024 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 6 ms 896 KB Output is correct
14 Correct 6 ms 896 KB Output is correct
15 Correct 6 ms 1024 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 5 ms 896 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 6 ms 1024 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 6 ms 896 KB Output is correct
14 Correct 6 ms 896 KB Output is correct
15 Correct 6 ms 1024 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 85 ms 1272 KB Output is correct
18 Correct 6 ms 896 KB Output is correct
19 Correct 22 ms 1024 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 129 ms 1272 KB Output is correct
22 Correct 17 ms 1024 KB Output is correct
23 Correct 6 ms 896 KB Output is correct
24 Correct 28 ms 1152 KB Output is correct
25 Correct 20 ms 1024 KB Output is correct
26 Correct 37 ms 1144 KB Output is correct
27 Correct 158 ms 1272 KB Output is correct
28 Correct 161 ms 1400 KB Output is correct
29 Correct 167 ms 1272 KB Output is correct
30 Correct 164 ms 1400 KB Output is correct
31 Correct 165 ms 1400 KB Output is correct
32 Correct 166 ms 1400 KB Output is correct
33 Correct 167 ms 1400 KB Output is correct
34 Correct 169 ms 1400 KB Output is correct
35 Correct 170 ms 1400 KB Output is correct
36 Correct 173 ms 1400 KB Output is correct
37 Correct 172 ms 1400 KB Output is correct