Submission #509638

#TimeUsernameProblemLanguageResultExecution timeMemory
509638socpiteNoM (RMI21_nom)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define f first #define s second const int maxn = 4e3+5; const int mod = 1e9+7; typedef long long ll; int n, m; ll dp[maxn][maxn][2]; int pos[maxn]; ll f(int i, int j, int k){ if(i == n)return k==0; else if(dp[i][j][k] != -1)return dp[i][j][k]; else{ int gap = pos[i]-i; dp[i][j][k] = 0; int p2 = n/2 - j - (i-j)/2; if(p2)dp[i][j][k]+=f(i+1, j+1, k)*p2*2%mod; if(j)dp[i][j][k]+=f(i+1, j-1, k)*j%mod; if(gap >= 2)dp[i][j][k]+=f(i+2, j, k^1)*p2*2%mod*(gap-1)%mod; dp[i][j][k]%=mod; //cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl; return dp[i][j][k]; } } int main(){ memset(dp, -1, sizeof(dp)); cin >> n >> m; n*=2; int crr = 0; for(int i = 0; i < m-n%m; i++){ int st = crr+n/m; for(int j = 0; j < n/m; j++)pos[crr++]=st; } for(int i = 0; i < n%m; i++){ int st = crr+n/m+1; for(int j = 0; j < n/m+1; j++)pos[crr++]=st; } ll ans = f(0, 0, 0)- f(0, 0, 1); if(ans < 0)ans+=mod; cout << ans; } #include<bits/stdc++.h> using namespace std; #define f first #define s second const int maxn = 4e3+5; const int mod = 1e9+7; typedef long long ll; int n, m; ll dp[maxn][maxn][2]; int pos[maxn]; ll f(int i, int j, int k){ if(i == n)return k==0; else if(dp[i][j][k] != -1)return dp[i][j][k]; else{ int gap = pos[i]-i; dp[i][j][k] = 0; int p2 = n/2 - j - (i-j)/2; if(p2)dp[i][j][k]+=f(i+1, j+1, k)*p2*2%mod; if(j)dp[i][j][k]+=f(i+1, j-1, k)*j%mod; if(gap >= 2)dp[i][j][k]+=f(i+2, j, k^1)*p2*2%mod*(gap-1)%mod; dp[i][j][k]%=mod; //cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl; return dp[i][j][k]; } } int main(){ memset(dp, -1, sizeof(dp)); cin >> n >> m; n*=2; int crr = 0; for(int i = 0; i < m-n%m; i++){ int st = crr+n/m; for(int j = 0; j < n/m; j++)pos[crr++]=st; } for(int i = 0; i < n%m; i++){ int st = crr+n/m+1; for(int j = 0; j < n/m+1; j++)pos[crr++]=st; } ll ans = f(0, 0, 0)- f(0, 0, 1); if(ans < 0)ans+=mod; cout << ans; }

Compilation message (stderr)

Main.cpp:56:11: error: redefinition of 'const int maxn'
   56 | const int maxn = 4e3+5;
      |           ^~~~
Main.cpp:7:11: note: 'const int maxn' previously defined here
    7 | const int maxn = 4e3+5;
      |           ^~~~
Main.cpp:57:11: error: redefinition of 'const int mod'
   57 | const int mod = 1e9+7;
      |           ^~~
Main.cpp:8:11: note: 'const int mod' previously defined here
    8 | const int mod = 1e9+7;
      |           ^~~
Main.cpp:61:5: error: redefinition of 'int n'
   61 | int n, m;
      |     ^
Main.cpp:12:5: note: 'int n' previously declared here
   12 | int n, m;
      |     ^
Main.cpp:61:8: error: redefinition of 'int m'
   61 | int n, m;
      |        ^
Main.cpp:12:8: note: 'int m' previously declared here
   12 | int n, m;
      |        ^
Main.cpp:63:4: error: redefinition of 'll dp [4005][4005][2]'
   63 | ll dp[maxn][maxn][2];
      |    ^~
Main.cpp:14:4: note: 'll dp [4005][4005][2]' previously declared here
   14 | ll dp[maxn][maxn][2];
      |    ^~
Main.cpp:64:5: error: redefinition of 'int pos [4005]'
   64 | int pos[maxn];
      |     ^~~
Main.cpp:15:5: note: 'int pos [4005]' previously declared here
   15 | int pos[maxn];
      |     ^~~
Main.cpp:53:11: error: redefinition of 'll first(int, int, int)'
   53 | #define f first
      |           ^~~~~
Main.cpp:66:4: note: in expansion of macro 'f'
   66 | ll f(int i, int j, int k){
      |    ^
Main.cpp:4:11: note: 'll first(int, int, int)' previously defined here
    4 | #define f first
      |           ^~~~~
Main.cpp:17:4: note: in expansion of macro 'f'
   17 | ll f(int i, int j, int k){
      |    ^
Main.cpp:82:5: error: redefinition of 'int main()'
   82 | int main(){
      |     ^~~~
Main.cpp:33:5: note: 'int main()' previously defined here
   33 | int main(){
      |     ^~~~