/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 13ms 796.0 KiB
#3 Accepted 8ms 844.0 KiB
#4 Accepted 14ms 668.0 KiB
#5 Accepted 17ms 748.0 KiB
#6 Accepted 8ms 988.0 KiB
#7 Accepted 22ms 796.0 KiB
#8 Accepted 64ms 588.0 KiB
#9 Accepted 45ms 2.246 MiB
#10 Accepted 50ms 2.195 MiB
#11 Accepted 29ms 2.195 MiB
#12 Accepted 52ms 16.758 MiB
#13 Accepted 53ms 16.77 MiB
#14 Accepted 56ms 16.746 MiB
#15 Accepted 53ms 17.039 MiB
#16 Accepted 53ms 16.75 MiB
#17 Accepted 48ms 16.758 MiB
#18 Accepted 51ms 16.754 MiB
#19 Accepted 57ms 16.922 MiB
#20 Accepted 53ms 16.77 MiB
#21 Accepted 242ms 65.867 MiB
#22 Accepted 226ms 65.871 MiB
#23 Accepted 260ms 65.867 MiB
#24 Accepted 255ms 65.824 MiB
#25 Accepted 322ms 65.867 MiB
#26 Accepted 225ms 65.996 MiB
#27 Accepted 233ms 65.871 MiB
#28 Accepted 244ms 65.867 MiB
#29 Accepted 254ms 65.867 MiB
#30 Accepted 250ms 65.867 MiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=1000000007;
typedef long long ll;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    	int n,m;
    	cin>>n>>m;
    	char ch[n][m];
    	for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++)cin>>ch[i][j];
    	vector<vector<int>>L(n+1,vector<int>(m+1,0));
    	vector<vector<int>>R(n+1,vector<int>(m+1,0));
    	vector<vector<int>>U(n+1,vector<int>(m+1,0));
    	vector<vector<int>>D(n+1,vector<int>(m+1,0));
    	for(int i=0;i<n;i++){
    		int cnt=0;
    		for(int j=0;j<m;j++){
    			if(ch[i][j]=='+')cnt++;
    			else cnt=0;
    			L[i][j]=cnt;
    		}
    		cnt=0;
    		for(int j=m-1;j>=0;j--){
    			if(ch[i][j]=='+')cnt++;
    			else cnt=0;
    			R[i][j]=cnt;
    		}
    	}
    	for(int i=0;i<m;i++){
    		int cnt=0;
    		for(int j=0;j<n;j++){
    			if(ch[j][i]=='+')cnt++;
    			else cnt=0;
    			U[j][i]=cnt;
    		}
    		cnt=0;
    		for(int j=n-1;j>=0;j--){
    			if(ch[j][i]=='+')cnt++;
    			else cnt=0;
    			D[j][i]=cnt;
    		}
    	}
    	int ans=0;
    	for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++){
    		if(ch[i][j]=='+'){
    			int mn=min({U[i][j],L[i][j],R[i][j],D[i][j]});
    			mn--;
    			ans=max(ans,mn*4+1);
    		}
    	}
    	cout<<ans<<"\n";
    	
    	
    
    
}

    
    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU Divisonal Contest Problem Testing Round
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-05 19:05:34
Judged At
2024-12-05 19:05:34
Judged By
Score
100
Total Time
322ms
Peak Memory
65.996 MiB