Cod sursa(job #1710261)

Utilizator HealeruDaniel Guramulta Healeru Data 28 mai 2016 18:36:54
Problema Padure2 Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.99 kb
#include <fstream>
#include <vector>
#include <map>
#include <iostream>
using namespace std;

const int MOD = 2000003;

int currentX{ 1 }, currentY{ 1 }, N, M, Clen;
map<pair<int, int>, int> currentPosible;


int isInMap(int x, int y) {
	map<pair<int,int>, int>::iterator it;
	for (it = currentPosible.begin(); it != currentPosible.end(); ++it) {
		if (it->first.first == x && it->first.second == y)
			return 1;
	}
	return 0;
}



int solve(int x, int y) {
	if (x == 1 && y == 1) {
		return 1;
	}

	if (x < 1 || y < 1) {
		return 0;
	}
	if (!isInMap(x, y)) {
		currentPosible[make_pair(x, y)] = (solve(x - 1, y) + solve(x, y - 1)) % MOD;
	}
	return currentPosible[make_pair(x, y)];

}

void read() {
	ifstream in("padure2.in");
	in >> N >> M;
	in >> Clen;
	int x, y;
	while(in>>x>>y) {
		currentPosible[make_pair(x, y)] = 0;
	}
	in.close();
}

int main() {
	read();
	ofstream out("padure2.out");
	out << (solve(N, M) % MOD);
	out.close();
	return 0;

}