QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619388#8635. 圆Daniel777Compile Error//C++141.6kb2024-10-07 14:04:042024-10-07 14:04:06

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 14:04:06]
  • 评测
  • [2024-10-07 14:04:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5005,mod = 998244353;
int f[2][N][3][3],n,ans[N];
int now,lst = 1;
ll inv[N],Sum;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    f[now][0][0][0] = f[now][0][2][2] = mod-1;
    f[now][0][1][0] = f[now][0][0][1] = 1;
    for(int i = 3;i <= n;i++)
    {
        swap(now,lst);
        memset(dp[now],0,sizeof(dp[now]));
        for(int j = 0;j <= i-3;j++)
        {
            for(int x = 0;x < 3;x++)
            {
                for(int y = 0;y < 3;y++)
                {
                    f[now][j+(y==2)][x][y+(y!=2)] = (f[now][j+(y==2)][x][y+(y!=2)] + f[lst][j][x][y])%mod;
                    f[now][j][x][0] = (f[now][j][x][0] + mod - f[lst][j][x][y])%mod;//这里容斥掉
                }
            }
        }
    }
    for(int j = 0;j <= n-2;j++)
        for(int x = 0;x < 3;x++)
            for(int y = 0;y < 3;y++)
            {
                if(x + y >= 3) ans[j+x+y-2] = (ans[j+x+y-2] + f[now][j][x][y])%mod;
                else ans[j] = (ans[j] + f[now][j][x][y])%mod;
            }
    ans[n] = 0;
    inv[1] = 1;
    for(int i = 2;i <= n;i++) inv[i] = mod - mod/i*inv[mod%i]%mod;
    for(int i = 0;i < n;i++)
    {
        //cout<<i<<" "<<ans[i]<<"\n";
        ll res = 1,tmp = 1;
        for(int j = 0;j < i;j++)
        {
            tmp = tmp*(i-j)%mod*inv[n-j]%mod;
            res = (res + tmp)%mod;
        }
        //cout<<res<<"\n";
        Sum = (Sum + ans[i]*res)%mod;
    }
    cout<<Sum<<"\n";
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:17:16: error: ‘dp’ was not declared in this scope
   17 |         memset(dp[now],0,sizeof(dp[now]));
      |                ^~