Submission #1158042

#TimeUsernameProblemLanguageResultExecution timeMemory
1158042nguynTents (JOI18_tents)C++20
100 / 100
104 ms70992 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 3e3 + 5; const int mod = 1e9 + 7; int n, m; int f[N][N]; void add(int &x, int y) { if (y < 0) x += mod; x += y; if (x >= mod) x -= mod; } signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n >> m; for (int i = 0; i <= max(m, n); i++) { f[i][0] = f[0][i] = 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { add(f[i][j], (f[i - 1][j - 1] * 4 * j + f[i - 1][j]) % mod); if (i > 1) add(f[i][j], f[i - 2][j - 1] * j % mod * (i - 1) % mod); if (j > 1) add(f[i][j], f[i - 1][j - 2] * (j * (j - 1) / 2 % mod) % mod); } } int res = f[n][m]; add(res, -1); cout << res; }

Compilation message (stderr)

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