fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 9;
  5.  
  6. int main() {
  7. int n, x, y, mt[MAX_SIZE +1][MAX_SIZE + 1];
  8. cin >> n >> x >> y;
  9. for (int i = 1; i <= n; ++i) {
  10. for (int j = 1; j <= n; ++j) {
  11. cin >> mt[i][j];
  12. }
  13. }
  14. int manhattanWay = x - 1 + y - 1, computingWay = 0;
  15. for (int i = 1; i < x; ++i) {
  16. computingWay += mt[i][y];
  17. }
  18. for (int j = 1; j < y; ++j) {
  19. computingWay += mt[1][j];
  20. }
  21. if (manhattanWay < computingWay) {
  22. cout << "Manhattan way";
  23. } else if (computingWay < manhattanWay) {
  24. cout << "Computing way";
  25. } else {
  26. cout << "Both ways";
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 5284KB
stdin
1 1 1
0


stdout
Both ways