Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <queue>
- using namespace std;
- struct node
- {
- int self = 10000000;
- bool can_i[5] {false};
- short counter = 0;
- bool finish = false;
- };
- node graph[502][502];
- void BFS(int START_X, int START_Y, int kierunek)
- {
- graph[START_X][START_Y].self = 0;
- queue<pair<int,int > > kolejka;
- queue<int> strzalki;
- //kolejka.push({START_X,START_Y});
- //strzalki.push(kierunek);
- //START tylko
- for(int i = 1; i <= 4; i++)
- {
- if(graph[START_X][START_Y].can_i[i])
- {
- if(kierunek == i)
- {
- }
- else
- {
- }
- }
- }
- int cur_x, cur_y, licznik;
- int cur_n, cur_t, cur_p, cur_l; //naprzod, tyl, prawo, lewo
- while(!kolejka.empty())
- {
- cur_x = kolejka.front().first;
- cur_y = kolejka.front().second;
- cur_str = strzalki.front();
- cout << cur_x << " " << cur_y << endl;
- kolejka.pop();
- strzalki.pop();
- //dol gora prawo lewo
- switch(cur_str)
- {
- case 1:
- cur_n = 1;
- cur_t = 2;
- cur_p = 4;
- cur_l = 3;
- break;
- case 2:
- cur_n = 2;
- cur_t = 1;
- cur_p = 3;
- cur_l = 4;
- break;
- case 3:
- cur_n = 3;
- cur_t = 4;
- cur_p = 1;
- cur_l = 2;
- break;
- case 4:
- cur_n = 4;
- cur_t = 3;
- cur_p = 2;
- cur_l = 1;
- break;
- }
- if(graph[cur_x][cur_y].can_i[cur_n])
- {
- if()
- }
- }
- }
- int main()
- {
- int n, m, kier;
- string wej;
- string tab;
- string::iterator found;
- cin >> n >> m >> wej;
- if(wej == "DOL")
- kier = 1;
- if(wej == "GORA")
- kier = 2;
- if(wej == "PRAWO")
- kier = 3;
- if(wej == "LEWO")
- kier = 4;
- int start_x, start_y, finish_x, finish_y;
- for(int i = 0; i < 2*n+1; i++)
- {
- cin >> tab;
- if(i == 0 || i == 2*n+1)
- continue;
- found = find(tab.begin(), tab.end(), 'S');
- if(found != tab.end())
- {
- start_x = i/2;
- start_y = (found - tab.begin())/2;
- }
- found = find(tab.begin(), tab.end(), 'R');
- if(found != tab.end())
- {
- finish_x = i/2;
- finish_y = (found - tab.begin())/2;
- }
- if(i % 2 == 1)
- {
- for(int j = 2; j < 2*m+1; j += 2)
- {
- if(tab[j] == '.')
- {
- graph[i/2][j/2 - 1].can_i[3] = true;
- graph[i/2][j/2 - 1].counter++;
- graph[i/2][j/2].can_i[4] = true;
- graph[i/2][j/2].counter++;
- }
- }
- }
- if(i % 2 == 0)
- {
- for(int j = 1; j < 2*m+1; j += 2)
- {
- if(tab[j] == '.')
- {
- graph[i/2 - 1][j/2].can_i[1] = true;
- graph[i/2 - 1][j/2].counter++;
- graph[i/2][j/2].can_i[2] = true;
- graph[i/2][j/2].counter++;
- }
- }
- }
- }
- cout << endl << "d g p l";
- cout << endl << endl;
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < m; j++)
- {
- for(int k = 1; k <= 4; k++)
- {
- cout << graph[i][j].can_i[k];
- }
- cout << " ";
- }
- cout << endl;
- }
- BFS(start_x, start_y,kier);
- //cout << graph[finish_x][finish_y].self;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement