50分求调,玄关QwQ
查看原帖
50分求调,玄关QwQ
1022674
Wei_Zheng2012楼主2024/7/28 11:15
#include <iostream>
using namespace std;

const int MAXN = 1005;
char c[MAXN][MAXN];
int n, m, dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};

int main() {
    cin >> n >> m;
    
    char mx = 'A', ch = 'A';
    
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> c[i][j];
            mx = max(mx, c[i][j]);
        }
    }
    
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (c[i][j] == mx) {
                for (int k = 0; k < 4; ++k) {
                    int x = i + dx[k], y = j + dy[k];
                    if (x >= 1 && x <= n && y >= 1 && y <= m && c[x][y] != '#') {
                        ch = max(ch, c[x][y]);
                    }
                }
            }
        }
    }
    
    if (mx != ch) {
        cout << mx;
    }
    cout << ch << endl;
    
    return 0;
}


Subtask #3 #9 WA,样例能通过,求调

2024/7/28 11:15
加载中...