Submission #1115511

#TimeUsernameProblemLanguageResultExecution timeMemory
1115511Neco_arcTents (JOI18_tents)C++17
0 / 100
2 ms8528 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define all(x) x.begin(), x.end() #define Neco "flagger" #define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin()) #define getbit(x,i) ((x) >> (i))&1) #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define cntbit(x) __builtin_popcountll(x) #define fi(i, a, b) for(int i = a; i <= b; i++) #define fid(i, a, b) for(int i = a; i >= b; i--) #define maxn (int) (5e3 + 5) using namespace std; const ll mod = 1e9 + 7; //972663749 mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rng); } int n, m; ll f[maxn][maxn]; inline void Add(ll &x, ll y) { if((x += y) >= mod) x -= mod; } ll C(ll x) { return (x * (x - 1) / 2) % mod; } void solve() { cin >> n >> m; fi(i, 0, n) fi(j, 0, m) { if(i == 0 || j == 0) { f[i][j] = 1; continue; }; ll val = (f[i - 1][j] + 4 * j % mod * f[i - 1][j - 1] % mod) % mod; Add(f[i][j], val); /// chon cung hang if(j >= 2) { ll val = C(j) * f[i - 1][j - 2]; Add(f[i][j], val); } /// chon cung cot if(i >= 2) { ll val = (i - 1) * j % mod * f[i - 2][j - 1]; Add(f[i][j], val); } } cout << (f[n][m] + mod - 1) % mod; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(Neco".inp", "r")) { freopen(Neco".inp", "r", stdin); freopen(Neco".out", "w", stdout); } int nTest = 1; // cin >> nTest; while(nTest--) { solve(); } return 0; }

Compilation message (stderr)

tents.cpp: In function 'int main()':
tents.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen(Neco".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(Neco".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...