Submission #35236

#TimeUsernameProblemLanguageResultExecution timeMemory
35236bql20000마스코트 (JOI13_mascots)C++14
100 / 100
283 ms213936 KiB
#include <bits/stdc++.h> #define ff(i,a,b) for(int i=(a), _b=(b); i<=_b; ++i) #define gg(i,a,b) for(int i=(a), _b=(b); i>=_b; --i) #define REP(i,b) for(int i=(0), _b=(b); i< _b; ++i) #define endl '\n' #define long long long #define ALL(x) (x).begin(), (x).end() #define Love(a) {cerr << #a << " = " << a << endl;} #define _ << "," << #define BIT(i, x) (((x)>>(i))&1) #define X first #define Y second #define NAME "MASCOTS" using namespace std; const int N = 3e3 + 7; const int MOD = 1e9 + 7; int n, m, k, a, b, c, d; long p[N*N], ans, dp[N][N], CC[N][N]; void Enter() { scanf("%d%d%d", &m, &n, &k); a = N; b = N; ff(i, 1, k) { int x , y; scanf("%d%d", &x, &y); a = min(a, x); c = max(c, x); b = min(b, y); d = max(d, y); } p[0] = 1; ff(i, 1, n*m) p[i] = p[i-1] * i % MOD; ans = p[(c-a+1)*(d-b+1)-k]; } inline void Add(long &a, long b) { a += b; if (a > MOD) a -= MOD; } void Init() { int V = max(m, n); ff(i, 0, V) CC[0][i] = 1; ff(i, 1, V) ff(j, i, V) CC[i][j] = (CC[i-1][j-1] + CC[i][j-1]) % MOD; } void Process() { Init(); dp[m][n] = 1; gg(i, m, 1) gg(j, n, 1) { if (i < m) Add(dp[i][j], dp[i+1][j] * p[j] % MOD); if (j < n) Add(dp[i][j], dp[i][j+1] * p[i] % MOD); } printf("%d", ans * dp[c-a+1][d-b+1] % MOD * CC[a-1][m-(c-a+1)] % MOD * CC[b-1][n-(d-b+1)] % MOD); } int main() { //ios_base::sync_with_stdio(0); cin.tie(0); //freopen(NAME".inp", "r", stdin); //freopen(NAME".out", "w", stdout); Enter(); Process(); return 0; }

Compilation message (stderr)

mascots.cpp: In function 'void Process()':
mascots.cpp:66:100: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
     printf("%d", ans * dp[c-a+1][d-b+1] % MOD * CC[a-1][m-(c-a+1)] % MOD * CC[b-1][n-(d-b+1)] % MOD);
                                                                                                    ^
mascots.cpp: In function 'void Enter()':
mascots.cpp:25:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &m, &n, &k);
                                ^
mascots.cpp:32:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x, &y);
                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...