Submission #34002

#TimeUsernameProblemLanguageResultExecution timeMemory
34002huynd2001마스코트 (JOI13_mascots)C++14
0 / 100
0 ms72492 KiB
/*huypheu 3 3 2 1 2 2 3 */ #include <bits/stdc++.h> #define mod 1000000007 using namespace std; int f[3007][3007]; int prep[9000007]; signed main() { int n,m; cin >> n >> m; int k; cin >> k; prep[0]=1; for(int i=1;i<=n*m;i++) prep[i]=(prep[i-1]*i)%mod; int misx=n+1,masx=0,misy=n+1,masy=0; for(int i=1;i<=k;i++) { int a,b; cin >> a >> b; misx=min(misx,a); masx=max(masx,a); misy=min(misy,b); masy=max(masy,b); } int lx,ly; if(k==0) lx=0,ly=0; else lx=masx-misx+1,ly=masy-misy+1; f[lx][ly]=prep[lx*ly-k]; // cout << f[lx][ly] << endl; // cout << lx << " " << ly << endl; for(int i=lx;i<=n;i++) { for(int j=ly;j<=m;j++) { if(i==lx && j==ly) continue; if(i>lx) f[i][j]=(f[i][j]+(f[i-1][j]*prep[j])*((i!=n)+1))%mod; if(j>ly) f[i][j]=(f[i][j]+(f[i][j-1]*prep[i])*((j!=m)+1))%mod; } } cout << f[n][m] << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...