#include <iostream>
using namespace std;
/*
Ideea generala de rezolvare:
Dupa ce calculam ambele tipuri de distante, le comparam si
afisam mesajul cerut.
Pasii de rezolvare:
Declaram si citim datele de intrare.
Declaram variabilele "manSum" si "compSum" pe care le initializam cu valoarea "0"
Facem suma dintre distanta liniilor si distanta coloanelor, pe care o salvam in "manSum".
- Parcurgem prima linie a matricei, pana la coordonata coloanei data de variabila "y",
facand suma valorilor elementelor pe care o salvam in "manSum".
- Parcurgem coloana matricei data de coordonata "y"
incepand de la linia "1" pana la linia "x",
si facem suma valorilor elementelor pe care o salvam in "manSum".
Comparam cele doua variabile si afisam ce se cere.
Teste:
3 2 2
0 1 2
3 4 5
1 2 3
-> Computing way
4 3 3
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
-> Manhattan way
*/
const int MAX_SIZE = 5;
int main() {
int n, x, y;
cin >> n >> x >> y;
int mt[MAX_SIZE + 1][MAX_SIZE +1] = {0};
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
cin >> mt[i][j];
}
}
int manSum = (x - 1) + (y - 1);
int compSum = 0;
for (int i = 1; i < y; ++i) {
compSum += mt[1][i];
}
for (int i = 1; i < x; ++i) {
compSum += mt[i][y];
}
if (manSum < compSum) {
cout << "Manhattan way";
} else if (compSum < manSum) {
cout << "Computing way";
} else {
cout << "Both ways";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwovKgpJZGVlYSBnZW5lcmFsYSBkZSByZXpvbHZhcmU6CkR1cGEgY2UgY2FsY3VsYW0gYW1iZWxlIHRpcHVyaSBkZSBkaXN0YW50ZSwgbGUgY29tcGFyYW0gc2kgCmFmaXNhbSBtZXNhanVsIGNlcnV0LgoKClBhc2lpIGRlIHJlem9sdmFyZToKRGVjbGFyYW0gc2kgY2l0aW0gZGF0ZWxlIGRlIGludHJhcmUuCkRlY2xhcmFtIHZhcmlhYmlsZWxlICJtYW5TdW0iIHNpICJjb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