"Jane and the Frost Giants "c++"" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "Jane and the Frost Giants "c++"" answered properly. Developers are finding an appropriate answer about Jane and the Frost Giants "c++" related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like Jane and the Frost Giants "c++". Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on Jane and the Frost Giants "c++".
Jane and the Frost Giants
#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
char grid[201][201];
int peek[201][201], step[201][201];
bool grid_visited[201][201];
queue<int> xfire, yfire;
int Y = 0, X = 0;
void rise_spred_BFS() {
while (!xfire.empty()) {
int y = yfire.front();
int x = xfire.front();
yfire.pop();
xfire.pop();
for (int i = 0; i < 4; i++) {
int y_temp = y + dy[i], x_temp = x + dx[i];
if (-1 < y_temp && -1 < x_temp && y_temp < Y && x_temp < X && grid[y_temp][x_temp] == '.' &&
peek[y_temp][x_temp] < 1) {
yfire.push(y_temp);
xfire.push(x_temp);
peek[y_temp][x_temp] = peek[y][x] + 1;
}
}
}
}
int run_BFS(int y, int x) {
if (y == 0 || x == 0 || y == Y - 1 || x == X - 1) {
return 1;
}
step[y][x] = 1;
queue<int> Yfire, Xfire;
Yfire.push(y);
Xfire.push(x);
grid_visited[y][x] = true;
while (!Yfire.empty()) {
int yy = Yfire.front(), xx = Xfire.front();
Yfire.pop();
Xfire.pop();
for (int i = 0; i < 4; i++) {
int y_temp = yy + dy[i], x_temp = xx + dx[i];
if (-1 < y_temp && -1 < x_temp && y_temp < Y && x_temp < X && !grid_visited[y_temp][x_temp] && (peek[y_temp][x_temp] == 0 || step[yy][xx] + 1 < peek[y_temp][x_temp]) && grid[y_temp][x_temp] == '.') {
if (y_temp == 0 || x_temp == 0 || y_temp == Y - 1 || x_temp == X - 1) {
return step[yy][xx] + 1;
}
Yfire.push(y_temp);
Xfire.push(x_temp);
step[y_temp][x_temp] = step[yy][xx] + 1;
grid_visited[y_temp][x_temp] = true;
}
}
}
return -1;
}
bool found;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int till;
cin >> till;
for (int z = 0; z < till; z++) {
cin >> Y >> X;
found = false;
int gy = 0, gx = 0, fy = 0, fx = 0;
memset(peek, 0, sizeof(peek));
for (int y = 0; y < Y; y++) {
cin >> grid[y];
for (int x = 0; x < X; x++) {
if (grid[y][x] == 'F') {
yfire.push(y);
xfire.push(x);
peek[y][x] = 1;
} else if (!found && grid[y][x] == 'J') {
gy = y;
gx = x;
found = true;
}
}
}
rise_spred_BFS();
memset(grid_visited, false, sizeof(grid_visited));
memset(step, 0, sizeof(step));
int answer = run_BFS(gy, gx);
if (answer == -1) {
cout << "Case " << (z + 1) << ": IMPOSSIBLE" << endl;
} else
cout << "Case " << (z + 1) << ": " << answer << endl;
}
return 0;
}
All those coders who are working on the TypeScript based application and are stuck on Jane and the Frost Giants "c++" can get a collection of related answers to their query. Programmers need to enter their query on Jane and the Frost Giants "c++" related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Jane and the Frost Giants "c++" for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of Jane and the Frost Giants "c++" while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "Jane and the Frost Giants "c++"". Visit this developer's friendly online web community, CodeProZone, and get your queries like Jane and the Frost Giants "c++" resolved professionally and stay updated to the latest TypeScript updates.