Pagini recente » Cod sursa (job #1756649) | Cod sursa (job #50243) | Cod sursa (job #2189582) | Cod sursa (job #2576106) | Cod sursa (job #519784)
Cod sursa(job #519784)
#include <fstream>
#include <vector>
#include <queue>
using namespace std;
const int D1[] = {0, 1, 0, -1},
D2[] = {1, 0, -1, 0};
int N, M, K;
int V[152][152], enter = 1;
bool Key[22502], InQueue[22502], S[152][152], Open[152][152];
vector<pair<int, int> > Where[150 * 150 + 1];
queue<int> Q;
int getCod(int x, int y)
{
return (x - 1) * M + y;
}
pair<int, int> getCoord(int cod)
{
int x = (cod % M == 0 ? cod / M : cod / M + 1);
cod -= (x - 1) * M;
return make_pair(x, cod);
}
int main()
{
ifstream fin("castel.in");
ofstream fout("castel.out");
fin >> N >> M >> K;
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= M; ++j)
{
fin >> V[i][j];
Where[V[i][j]].push_back(make_pair(i, j));
}
pair<int, int> coord = getCoord(K);
S[coord.first][coord.second] = true;
Key[K] = true;
Q.push(K);
while (!Q.empty())
{
int now = Q.front(); Q.pop();
int nowx = getCoord(now).first, nowy = getCoord(now).second;
for (vector<pair<int, int> >::iterator it = Where[now].begin(); it != Where[now].end(); ++it)
}
fout << enter;
fin.close();
fout.close();
}