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. int manhattanWay = x - 1 + y - 1, computingWay = 0;
  10. for (int i = 1; i <= n; ++i) {
  11. for (int j = 1; j <= n; ++j) {
  12. cin >> mt[i][j];
  13. if (i < x && j == y || (j < y && i == 1)) {
  14. computingWay += mt[i][j];
  15. }
  16. }
  17. }
  18. if (manhattanWay < computingWay) {
  19. cout << "Manhattan way";
  20. } else if (computingWay < manhattanWay) {
  21. cout << "Computing way";
  22. } else {
  23. cout << "Both ways";
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5284KB
stdin
1 1 1
0
-> Both ways
stdout
Both ways