fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. short width; // the number of cells on the X axis
  8. cin >> width; cin.ignore();
  9. short height; // the number of cells on the Y axis
  10. cin >> height; cin.ignore();
  11. string *node = new string[height];
  12. short x, y;
  13. for (y = 0; y < height; ++y)
  14. {
  15. getline(cin, node[y]);
  16. }
  17. for (y = 0; y < height; ++y)
  18. {
  19. for (x = 0; x < width; ++x)
  20. {
  21. if (node[y][x] == '0')
  22. {
  23. cout << x << ' ' << y << ' ';
  24. short x2, y2, ansX = -1, ansY = -1;
  25. for (x2 = x+1; x2 < width; ++x2)
  26. {
  27. if (node[y][x2] == '0')
  28. {
  29. ansX = x2;
  30. ansY = y;
  31. break;
  32. }
  33. }
  34. cout << ansX << ' ' << ansY << ' ';
  35. ansX = -1; ansY = -1;
  36. for (y2 = y+1; y2 < height; ++y2)
  37. {
  38. if (node[y2][x] == '0')
  39. {
  40. ansX = x;
  41. ansY = y2;
  42. break;
  43. }
  44. }
  45. cout << ansX << ' ' << ansY << '\n';
  46. x = x2-1;
  47. }
  48. }
  49. }
  50. }
Success #stdin #stdout 0s 15240KB
stdin
2 2
00
0.
stdout
0 0 1 0 0 1
1 0 -1 -1 -1 -1
0 1 -1 -1 -1 -1