Cod sursa(job #254462)

Utilizator ProtomanAndrei Purice Protoman Data 7 februarie 2009 12:18:10
Problema Kdrum Scor 0
Compilator cpp Status done
Runda Stelele Informaticii 2009, clasele 9-10, ziua 2 Marime 1.12 kb
// pnm hibride:)
#include <algorithm>
#include <stdio.h>

using namespace std;

int n, m, k, sol, x1, x2, y1, y2;
int matNr[60][60];

void leeSimplu()
{
	int matAc[60][60];

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			matAc[i][j] = 2510;
	matAc[x1][y1] = 1;

	for (int act = 1; matAc[x2][y2] == 2510; act++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				if (matAc[i][j] == act)
				{
					matAc[i - 1][j] = min(matAc[i - 1][j], matAc[i][j] + 1);
					matAc[i + 1][j] = min(matAc[i + 1][j], matAc[i][j] + 1);
					matAc[i][j - 1] = min(matAc[i][j - 1], matAc[i][j] + 1);
					matAc[i][j + 1] = min(matAc[i][j + 1], matAc[i][j] + 1);
				}

	sol = matAc[x2][y2];
}

void leeMajor()
{
}

int main()
{
	freopen("kdrum.in", "r", stdin);
	freopen("kdrum.out", "w", stdout);

	scanf("%d %d %d", &n, &m, &k);
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &matNr[i][j]);

	if (k == 1)
		leeSimplu();
	else leeMajor();

	printf("%d", sol);
	fclose(stdin);
	fclose(stdout);
	return 0;
}