/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 8ms 540.0 KiB
#3 Accepted 198ms 560.0 KiB
#4 Accepted 219ms 540.0 KiB
#5 Accepted 52ms 540.0 KiB
#6 Accepted 307ms 560.0 KiB
#7 Time Exceeded ≥2097ms ≥540.0 KiB
#8 Accepted 27ms 540.0 KiB
#9 Accepted 27ms 796.0 KiB
#10 Accepted 27ms 840.0 KiB
#11 Time Exceeded ≥2091ms ≥812.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n,m; cin>>n>>m;
	char a[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	
	

	
	int ans = 0;
	int mx = 0;
	int f = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			
			if(a[i][j]=='+')
			{   
				f = 1;
				
				int p = 1;
				while(true)
				{
					int nw =0;
			   
			        for(int k=j+1;k<m;k++)
			        {
			       	     
			       	      
			    	     if(a[i][k]=='+') nw++;
			    	     else break;
			        }
			        // if(i==2 and j==5) cout<<nw<<endl;
			    
                   if(nw<p) break;
			        nw = 0;
			        for(int k = i+1;k<n;k++)
			        {

			    	   if(a[k][j]=='+') 
			    	   {

			    	   	 nw++;
			    	   	 
			    	   }
			    	   else break;
			        }

			        if(nw<p) break;
			        nw = 0;
			        for(int k = j-1;k>=0 ; k--)
			        {
			    	   if(a[i][k]=='+') nw++;
			    	   else break;
			        }
			        if(nw<p) break;
			        nw = 0;
			        for(int k = i-1;k>=0;k--)
			        {
			    	    if(a[k][j]=='+') nw++;
			    	    else break;
			        }
			    
			        if(nw<p) break;
			        // if(p==2)
			        // {
			        // 	cout<<i<<' '<<j<<endl;
			        // }
			        if(ans<((4*p)+1))
			        {
			        
				      

				       ans = 4*p+1;
			        }
			        p++;
			      }
				
				
				
			    

			 }
		}
	}

	cout<<max(ans,f)<<endl;
}
int32_t main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
    int t; cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}
// 1
// 7 7 
// + + + + + + +
// + - - + + + +
// + + + + + + +
// - - - + - + -
// + + + - + + +
// + + + - + + +
// - - - - - - - 

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:45:47
Judged At
2024-12-09 08:45:47
Judged By
Score
18
Total Time
≥2097ms
Peak Memory
≥840.0 KiB