Pagini recente » Cod sursa (job #717796) | Cod sursa (job #2768363) | Cod sursa (job #1521984) | Cod sursa (job #412595) | Cod sursa (job #1710182)
#include <fstream>
#include <vector>
using namespace std;
const int MAX = 1000000;
const int MOD = 2000003;
int currentX{ 1 }, currentY{ 1 }, N, M, Clen;
vector<pair<int, int>> Ciuperci;
int nr;
void BackT(int x, int y) {
if (x > N || y > M) {
return;
}
for (vector<pair<int, int>>::iterator it = Ciuperci.begin(); it != Ciuperci.end(); ++it) {
if (it->first == x && it->second == y) {
return;
}
}
if (x == N && y == M) {
nr++;
nr %= MOD;
}
else {
BackT(x + 1, y);
BackT(x, y + 1);
}
}
void read() {
ifstream in("padure2.in");
in >> N >> M;
in >> Clen;
for (int i = 0; i < Clen; ++i) {
int x, y;
in >> x >> y;
Ciuperci.push_back(make_pair(x, y));
}
in.close();
}
int main() {
read();
BackT(1, 1);
ofstream out("padure2.out");
out << nr;
out.close();
return 0;
}