Advertisement
iStrzalka

Untitled

Oct 12th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <queue>
  4. using namespace std;
  5.  
  6. struct node
  7. {
  8. int self = 10000000;
  9.  
  10. bool can_i[5] {false};
  11. short counter = 0;
  12.  
  13. bool finish = false;
  14. };
  15.  
  16. node graph[502][502];
  17.  
  18.  
  19. void BFS(int START_X, int START_Y, int kierunek)
  20. {
  21. graph[START_X][START_Y].self = 0;
  22. queue<pair<int,int > > kolejka;
  23. queue<int> strzalki;
  24. //kolejka.push({START_X,START_Y});
  25. //strzalki.push(kierunek);
  26.  
  27. //START tylko
  28. for(int i = 1; i <= 4; i++)
  29. {
  30. if(graph[START_X][START_Y].can_i[i])
  31. {
  32. if(kierunek == i)
  33. {
  34.  
  35. }
  36. else
  37. {
  38.  
  39. }
  40. }
  41. }
  42.  
  43.  
  44. int cur_x, cur_y, licznik;
  45. int cur_n, cur_t, cur_p, cur_l; //naprzod, tyl, prawo, lewo
  46. while(!kolejka.empty())
  47. {
  48. cur_x = kolejka.front().first;
  49. cur_y = kolejka.front().second;
  50. cur_str = strzalki.front();
  51.  
  52. cout << cur_x << " " << cur_y << endl;
  53.  
  54. kolejka.pop();
  55. strzalki.pop();
  56.  
  57. //dol gora prawo lewo
  58. switch(cur_str)
  59. {
  60. case 1:
  61. cur_n = 1;
  62. cur_t = 2;
  63. cur_p = 4;
  64. cur_l = 3;
  65. break;
  66. case 2:
  67. cur_n = 2;
  68. cur_t = 1;
  69. cur_p = 3;
  70. cur_l = 4;
  71. break;
  72. case 3:
  73. cur_n = 3;
  74. cur_t = 4;
  75. cur_p = 1;
  76. cur_l = 2;
  77. break;
  78. case 4:
  79. cur_n = 4;
  80. cur_t = 3;
  81. cur_p = 2;
  82. cur_l = 1;
  83. break;
  84. }
  85.  
  86. if(graph[cur_x][cur_y].can_i[cur_n])
  87. {
  88. if()
  89. }
  90.  
  91.  
  92.  
  93. }
  94. }
  95.  
  96.  
  97. int main()
  98. {
  99. int n, m, kier;
  100. string wej;
  101. string tab;
  102. string::iterator found;
  103. cin >> n >> m >> wej;
  104.  
  105. if(wej == "DOL")
  106. kier = 1;
  107. if(wej == "GORA")
  108. kier = 2;
  109. if(wej == "PRAWO")
  110. kier = 3;
  111. if(wej == "LEWO")
  112. kier = 4;
  113.  
  114. int start_x, start_y, finish_x, finish_y;
  115. for(int i = 0; i < 2*n+1; i++)
  116. {
  117. cin >> tab;
  118. if(i == 0 || i == 2*n+1)
  119. continue;
  120.  
  121. found = find(tab.begin(), tab.end(), 'S');
  122. if(found != tab.end())
  123. {
  124. start_x = i/2;
  125. start_y = (found - tab.begin())/2;
  126. }
  127. found = find(tab.begin(), tab.end(), 'R');
  128. if(found != tab.end())
  129. {
  130. finish_x = i/2;
  131. finish_y = (found - tab.begin())/2;
  132. }
  133.  
  134. if(i % 2 == 1)
  135. {
  136. for(int j = 2; j < 2*m+1; j += 2)
  137. {
  138. if(tab[j] == '.')
  139. {
  140. graph[i/2][j/2 - 1].can_i[3] = true;
  141. graph[i/2][j/2 - 1].counter++;
  142. graph[i/2][j/2].can_i[4] = true;
  143. graph[i/2][j/2].counter++;
  144. }
  145. }
  146. }
  147. if(i % 2 == 0)
  148. {
  149. for(int j = 1; j < 2*m+1; j += 2)
  150. {
  151. if(tab[j] == '.')
  152. {
  153. graph[i/2 - 1][j/2].can_i[1] = true;
  154. graph[i/2 - 1][j/2].counter++;
  155. graph[i/2][j/2].can_i[2] = true;
  156. graph[i/2][j/2].counter++;
  157. }
  158.  
  159. }
  160. }
  161. }
  162.  
  163. cout << endl << "d g p l";
  164. cout << endl << endl;
  165. for(int i = 0; i < n; i++)
  166. {
  167. for(int j = 0; j < m; j++)
  168. {
  169. for(int k = 1; k <= 4; k++)
  170. {
  171. cout << graph[i][j].can_i[k];
  172. }
  173. cout << " ";
  174. }
  175. cout << endl;
  176. }
  177.  
  178. BFS(start_x, start_y,kier);
  179. //cout << graph[finish_x][finish_y].self;
  180.  
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement