Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- char mat[n + 1][m + 1];
- int si, sj;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- cin >> mat[i][j];
- if(mat[i][j] == 'P') {
- si = i;
- sj = j;
- }
- }
- }
- queue<int> q;
- q.push(si); // indeks na red
- q.push(sj); // indeks na kolona
- q.push(0); // broj na cekori
- q.push(1); // dali ke se dzizam 1, 2 ili 3 cekori
- int di1[] = {-1, 1, 0, 0};
- int dj1[] = {0, 0, -1, 1};
- int di2[] = {-2, 2, 0, 0};
- int dj2[] = {0, 0, -2, 2};
- int di3[] = {-3, 3, 0, 0};
- int dj3[] = {0, 0, -3, 3};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement