wrong answer too long求助
查看原帖
wrong answer too long求助
1065628
Cute_zsz楼主2024/7/3 20:29
#include<bits/stdc++.h> 
using namespace std;

typedef long long ll;
const ll N = 1e3 + 10;

ll n, m;
string s, tmp;
char a[N][N], maxl = 'A';

int main(){
    ios::sync_with_stdio(0), cout.tie(0), cin.tie(0);

    cin >> n >> m;
    for(ll i = 1;i <= n;i ++){
        for(ll j = 1;j <= m;j ++){
            cin >> a[i][j];
            if(a[i][j] != '#') maxl = max(maxl, a[i][j]);
        }
    }

    s = maxl, tmp = s;

    for(ll i = 1;i <= n;i ++){
        for(ll j = 1;j <= m;j ++){
            if(a[i][j] == maxl){
                if((a[i + 1][j] != '#') && (a[i + 1][j] != maxl)) s = max(s, tmp + a[i + 1][j]);
                if((a[i - 1][j] != '#') && (a[i - 1][j] != maxl)) s = max(s, tmp + a[i - 1][j]);
                if((a[i][j + 1] != '#') && (a[i][j + 1] != maxl)) s = max(s, tmp + a[i][j + 1]);
                if((a[i][j - 1] != '#') && (a[i][j - 1] != maxl)) s = max(s, tmp + a[i][j - 1]);
            }
        }
    }

    cout << s << endl;

    return 0;
}

第6、7测试点Wrong Answer too long

2024/7/3 20:29
加载中...