Cod sursa(job #2839265)

Utilizator ptudortudor P ptudor Data 25 ianuarie 2022 17:47:51
Problema Padure2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.7 kb
#include <bits/stdc++.h>
#define int long long
using namespace std;

#ifdef LOCAL
ifstream in("in.in");
ofstream out("out.out");
#else
ifstream in("in.in");
ofstream out("out.out");

#endif

const int nmax = 5005,mod = 2000003;
int n, m, dp[nmax][nmax],c, v[nmax][nmax];

int32_t main() {
    in >> n >> m >> c;

    for (int i = 1; i <= c; i++) {
        int y, x;
        in >> y >> x;
        v[y][x] = 1;
    }
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if ((i == 1 && j == 1) || (v[i][j] == 1)) continue;

            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }

    out << dp[n][m] << "\n";
}