forked from Autoratch/Thailand-Olympiad-in-Informatics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoi10_goschool.cpp
49 lines (38 loc) · 847 Bytes
/
toi10_goschool.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int m,n,k;
cin >> m >> n >> k;
vector<vector<long long> > a(m);
for(int i = 0;i < m;i++) a[i].resize(n);
for(int i = 0;i < k;i++)
{
int x,y;
cin >> x >> y;
a[x-1][y-1] = -1;
}
bool f = false;
for(int i = 0;i < m;i++)
{
if(a[i][0]==-1) f = true;
if(f) a[i][0] = 0;
else a[i][0] = 1;
}
f = false;
for(int i = 0;i < n;i++)
{
if(a[0][i]==-1) f = true;
if(f) a[0][i] = 0;
else a[0][i] = 1;
}
for(int i = 1;i < m;i++) for(int j = 1;j < n;j++)
{
if(a[i][j]==-1) a[i][j] = 0;
else a[i][j] = a[i-1][j]+a[i][j-1];
}
cout << a[m-1][n-1];
}