Advertisement
savrasov

dfffffdsfgsdaff

Jun 6th, 2017
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. typedef long long ll;
  10. typedef long double ld;
  11.  
  12. char a[110][110];
  13.  
  14. int main()
  15. {
  16. ll n, m, x = 0, y = 0, i, j;
  17. cin >> n >> m;
  18. for(int i = 0; i < n; i++)
  19. for(int j = 0; j < m; j++)
  20. {
  21. cin >> a[i][j];
  22. if(a[i][j] == '#' && a[x][y] != '#')
  23. {
  24. x = i;
  25. y = j;
  26. }
  27. }
  28. cout << x << ' ' << y << endl;
  29. x--;
  30. y--;
  31. i = x;
  32. j = y + 1;
  33. while(x != i || y != j)
  34. {
  35. if(a[i + 1][j] == '#')
  36. {
  37. cout << i + 1 << ' ' << 1 + j << endl;
  38. j++;
  39. }
  40. else if(a[i - 1][j] == '#')
  41. {
  42.  
  43. cout << 1 + i << ' ' << 1 + j << endl;
  44. j--;
  45. }
  46. else if(a[i][j - 1] == '#')
  47. {
  48.  
  49. cout << 1 + i << ' ' << 1 + j << endl;
  50. i++;
  51. }
  52. else if(a[i][j + 1] == '#')
  53. {
  54.  
  55. cout << 1 + i << ' ' << 1 + j << endl;
  56. i--;
  57. }
  58. else if(a[i + 1][j - 1] == '#')
  59. {
  60.  
  61. cout << 1 + i << ' ' << 1 + j << endl;
  62. i++;
  63. }
  64. else if(a[i - 1][j - 1] == '#')
  65. {
  66.  
  67. cout << 1 + i << ' ' << 1 + j << endl;
  68. j--;
  69. }
  70. else if(a[i - 1][j + 1] == '#')
  71. {
  72.  
  73. cout << 1 + i << ' ' << 1 + j << endl;
  74. i--;
  75. }
  76. else if(a[i + 1][j + 1] == '#')
  77. {
  78.  
  79. cout << 1 + i << ' ' << 1 + j << endl;
  80. j++;
  81. }
  82. }
  83. return 0;
  84. }
  85. /*
  86. 5 4
  87. ....
  88. ..#.
  89. .##.
  90. ..#.
  91. ....
  92. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement