# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1101112 | 2024-10-15T14:49:23 Z | TgX_2 | Tents (JOI18_tents) | C++17 | 78 ms | 71252 KB |
/*----------------------------- Author : TgX.2 11Ti - K28 - CHV -----------------------------*/ #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i += 1) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i -= 1) #define fi first #define se second #define len(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() #define _ << " " << #define __ << "\n" #define ___ << " " #define ______________TgX______________ main() #define int long long #define intmax 1e9 #define intmin -1e9 #define llongmax 1e18 #define llongmin -1e18 #define memo(a, val) memset((a), (val), sizeof((a))) struct custom { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; template<class T1, class T2> using cmap = unordered_map<T1, T2, custom>; template<typename T1, typename T2> bool mini(T1 &a, T2 b) {if (a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi(T1 &a, T2 b) {if (a < b) a = b; else return 0; return 1;} /*-----------------------------*/ const int maxn = 3007; const int mod = 1e9 + 7; int n, m; int f[maxn][maxn]; int dp(int i, int j) { if (i < 0 or j < 0) return 0; if (i == 0 or j == 0) return 1; int &ans = f[i][j]; if (ans != -1) return ans; ans = 0; (ans += dp(i, j - 1)) % mod; (ans += ((4 * i) % mod * dp(i - 1, j - 1)) % mod) % mod; (ans += (i * (i - 1) / 2 % mod * dp(i - 2, j - 1)) % mod) % mod; (ans += ((i * (j - 1)) % mod * dp(i - 1, j - 2)) % mod) % mod; return ans; } void process() { cin >> n >> m; memo(f, -1); cout << (dp(n, m) - 1 + mod) % mod; } /*-----------------------------*/ ______________TgX______________ { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("temp.inp", "r")) { freopen("temp.inp", "r", stdin); freopen("temp.out", "w", stdout); } process(); cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." __ ; } /*==============================+ |INPUT | --------------------------------| ================================+ |OUTPUT | --------------------------------| ===============================*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 71128 KB | Output is correct |
2 | Correct | 10 ms | 71252 KB | Output is correct |
3 | Correct | 9 ms | 71248 KB | Output is correct |
4 | Correct | 9 ms | 70996 KB | Output is correct |
5 | Correct | 9 ms | 71252 KB | Output is correct |
6 | Correct | 9 ms | 71008 KB | Output is correct |
7 | Correct | 10 ms | 71252 KB | Output is correct |
8 | Correct | 9 ms | 70996 KB | Output is correct |
9 | Correct | 9 ms | 71160 KB | Output is correct |
10 | Correct | 9 ms | 71252 KB | Output is correct |
11 | Correct | 9 ms | 71252 KB | Output is correct |
12 | Correct | 10 ms | 71252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 71128 KB | Output is correct |
2 | Correct | 10 ms | 71252 KB | Output is correct |
3 | Correct | 9 ms | 71248 KB | Output is correct |
4 | Correct | 9 ms | 70996 KB | Output is correct |
5 | Correct | 9 ms | 71252 KB | Output is correct |
6 | Correct | 9 ms | 71008 KB | Output is correct |
7 | Correct | 10 ms | 71252 KB | Output is correct |
8 | Correct | 9 ms | 70996 KB | Output is correct |
9 | Correct | 9 ms | 71160 KB | Output is correct |
10 | Correct | 9 ms | 71252 KB | Output is correct |
11 | Correct | 9 ms | 71252 KB | Output is correct |
12 | Correct | 10 ms | 71252 KB | Output is correct |
13 | Correct | 10 ms | 71252 KB | Output is correct |
14 | Correct | 10 ms | 70996 KB | Output is correct |
15 | Incorrect | 78 ms | 71252 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |