Submission #479171

#TimeUsernameProblemLanguageResultExecution timeMemory
479171NeosZapina (COCI20_zapina)C++14
110 / 110
400 ms2116 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<ll, ll> ii; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<vii> vvii; #define task "test" #define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ ) #define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- ) #define sz(x) (int)x.size() #define fi first #define se second #define all(x) x.begin(), x.end() #define numBit(x) __builtin_popcount(x) #define lb lower_bound #define ub upper_bound #define ar array #define endl '\n' const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; const int N = 350 + 7; const ll inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; int n, C[N][N], dp[2][N][N]; bool avail[2][N][N]; int add(int x, int y) { x += y; if (x >= MOD) x -= MOD; return x; } int mul(int x, int y) { return 1LL * x * y % MOD; } int fexp(int x, int y) { int ans = 1; while (y > 0) { if (y & 1) ans = mul(ans, x); x = mul(x, x); y >>= 1; } return ans; } int DP(bool happy, int n, int k) { if (n == 0) return happy && (k == 0); if (avail[happy][n][k]) return dp[happy][n][k]; avail[happy][n][k] = 1; int ans = 0; forw(i, 0, k + 1) ans = add(ans, mul(C[k][i], DP(happy | (i == n), n - 1, k - i))); return dp[happy][n][k] = ans; } int main() { fastIO; forw(i, 0, N) forw(j, 0, min(1ll * N, i) + 1) if (j == 0 || j == i) C[i][j] = 1; else C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]); cin >> n; cout << DP(0, n, n) << endl; // happy, indx, remaining task }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...