Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 100;
- int tower[N + 10][N + 10];
- int ans[4];
- int main(){
- int row, col;
- scanf("%d%d", &row, &col);
- for(int i = 1; i <= row; ++i){
- for(int j = 1; j <= col; ++j){
- scanf("%d", &tower[i][j]);
- }
- }
- // North
- ans[0] = 0;
- for(int i = 1; i <= col; ++i){
- int cnt = 0;
- int last = 0;
- for(int j = 1; j <= row; ++j){
- if(tower[j][i] > last){
- last = tower[j][i];
- ++cnt;
- }
- }
- ans[0] += cnt;
- }
- // South
- ans[1] = 0;
- for(int i = 1; i <= col; ++i){
- int cnt = 0;
- int last = 0;
- for(int j = row; j >= 1; --j){
- if(tower[j][i] > last){
- last = tower[j][i];
- ++cnt;
- }
- }
- ans[1] += cnt;
- }
- // West
- ans[2] = 0;
- for(int i = 1; i <= row; ++i){
- int cnt = 0;
- int last = 0;
- for(int j = 1; j <= col; ++j){
- if(tower[i][j] > last){
- last = tower[i][j];
- ++cnt;
- }
- }
- ans[2] += cnt;
- }
- // East
- ans[3] = 0;
- for(int i = 1; i <= row; ++i){
- int cnt = 0;
- int last = 0;
- for(int j = col; j >= 1; --j){
- if(tower[i][j] > last){
- last = tower[i][j];
- ++cnt;
- }
- }
- ans[3] += cnt;
- }
- vector<int> tmp;
- int mx = 0;
- for(int i = 0; i < 4; ++i){
- if(ans[i] > mx){
- tmp.clear();
- mx = ans[i];
- tmp.push_back(i);
- } else if(ans[i] == mx){
- tmp.push_back(i);
- }
- }
- if(tmp.size() > 1){
- cout << "So many ways\n";
- } else if(tmp[0] == 0){
- cout << "North\n";
- } else if(tmp[0] == 1){
- cout << "South\n";
- } else if(tmp[0] == 2){
- cout << "West\n";
- } else if(tmp[0] == 3){
- cout << "East\n";
- }
- cout << mx;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement