/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 7ms 540.0 KiB
#3 Wrong Answer 13ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define bug(a) cout<<#a<<" : "<<a<<endl;

bool isValidColumn(int x, int c){
    if((0 <= x and x < c)) return true;
    else return false;
}
bool isValidRow(int x, int r){
    if((0 <= x and x < r)) return true;
    else return false;
}

void solve(){
   
    int r, c; cin >> r >> c;
    char v[r][c];

    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> v[i][j];
        }
    }    

    int ans = 0;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            if(v[i][j] == '+'){
                // bug(i);
                // bug(j);
                int cnt = 0;
                int iNeg = i - 1, iPos = i + 1, jNeg = j - 1, jPos = j + 1;
                while(1){
                    if((isValidRow(iNeg, r) and v[iNeg][j] == '+') and (isValidRow(iPos, r) and v[iPos][j] == '+') and (isValidColumn(jNeg, c) and v[i][jNeg] == '+') and (isValidColumn(jNeg, c) and v[i][jPos] == '+')){
                        cnt++;
                        iNeg--; iPos++; jNeg--; jPos++;
                    }else{
                        break;
                    }
                }
                // bug(cnt);
                int res = (cnt * 4) + 1;
                // bug(res);
                // cout<<endl;
                ans = max(ans, res);
            }
        }
        
    }
    cout<<ans<<endl;  
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t; cin>>t;
    while(t--)
        solve();

    return 0;
}   

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 08:11:18
Judged At
2024-12-09 08:11:18
Judged By
Score
2
Total Time
13ms
Peak Memory
540.0 KiB