Accepted
Code
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tc=1,tc1=1;
cin>>tc;
up:
while(tc--){
ll n,m;
cin>>n>>m;
char s[n][m];
for(ll i=0;i<n;i++){
for(ll j=0;j<m;j++){
cin>>s[i][j];
}
}
ll l[n][m],r[n][m],u[n][m],d[n][m],g=0;
for(ll i=0;i<n;i++){
ll c=0;
for(ll j=0;j<m;j++){
if(s[i][j]=='+'){
c++;
g=1;
}
else {
c=0;
}
l[i][j]=c;
}
}
for(ll i=0;i<n;i++){
ll c=0;
for(ll j=m-1;j>=0;j--){
if(s[i][j]=='+'){
c++;
}
else {
c=0;
}
r[i][j]=c;
}
}
for(ll i=0;i<m;i++){
ll c=0;
for(ll j=0;j<n;j++){
if(s[j][i]=='+'){
c++;
}
else {
c=0;
}
u[j][i]=c;
}
}
for(ll i=0;i<m;i++){
ll c=0;
for(ll j=n-1;j>=0;j--){
if(s[j][i]=='+'){
c++;
}
else {
c=0;
}
d[j][i]=c;
}
}
ll mx=g;
for(ll i=1;i<n-1;i++){
for(ll j=1;j<m-1;j++){
if(s[i][j]=='-'){
continue;
}
ll mn=min({l[i][j-1],r[i][j+1],d[i+1][j],u[i-1][j]});
mx=max(mx,mn*4+1);
}
}
cout<<mx<<'\n';
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1143 Plus of Pluses
- Contest
- LU IUJPC : Sylhet Division 2024 Replay Contest
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-12-10 10:32:37
- Judged At
- 2024-12-10 10:32:37
- Judged By
- Score
- 100
- Total Time
- 365ms
- Peak Memory
- 126.773 MiB