月赛D k=1为什么这么写不对

学术版

水星湖 @ 2023-12-24 18:12:00

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool f[105][105];
ll a[105][105];
int main() {
    int n,m,k,p,s;
    cin>>n>>m>>k>>p>>s;
    if(s)
    {
        for(int i=1;i<=s;i++)
        {
            int x,y;
            cin>>x>>y;
            f[x][y] = 1;
        }
    }
    a[1][1] = 1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            if(!f[i][j]&&!a[i][j])
                a[i][j] = (a[i-1][j] + a[i][j-1])%p;
        }
    if(k==0)
        cout<<a[n][m];
    else
        cout<<a[n][m]*(n+m-1)%p;
    return 0;
}

by Dws_t7760 @ 2023-12-24 18:18:40

@zrczrczrczrc 这么做肯定是错误的,给一组 hack 数据


input: 
2 3 1 10000 1
1 3

output:
10

``

by 水星湖 @ 2023-12-24 18:23:51

@t7760 艹 我悟了


|