Cod sursa(job #1710196)

Utilizator HealeruDaniel Guramulta Healeru Data 28 mai 2016 17:28:28
Problema Padure2 Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.92 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;
	}
	if (x == N && y == M) {
		nr++;
		nr %= MOD;
	}
	else {
		for (vector<pair<int, int>>::iterator it = Ciuperci.begin(); it != Ciuperci.end(); ++it) {
			if (it->first == x && it->second == y) {
				return;
			}
		}
		if (x == N) {
			BackT(x, y + 1);
			return;
		}
		if (y == M) {
			BackT(x + 1, y);
			return;
		}
		BackT(x + 1, y);
		BackT(x, y + 1);
	}
}


void read() {
	ifstream in("padure2.in");
	in >> N >> M;
	in >> Clen;
	int x, y;
	while(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;

}