Cod sursa(job #1710182)

Utilizator HealeruDaniel Guramulta Healeru Data 28 mai 2016 17:07:51
Problema Padure2 Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.84 kb
#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;

}