/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 7ms 724.0 KiB
#3 Accepted 57ms 560.0 KiB
#4 Accepted 69ms 720.0 KiB
#5 Accepted 17ms 780.0 KiB
#6 Accepted 94ms 560.0 KiB
#7 Accepted 767ms 572.0 KiB
#8 Accepted 29ms 560.0 KiB
#9 Accepted 23ms 540.0 KiB
#10 Accepted 23ms 796.0 KiB
#11 Time Exceeded ≥2098ms ≥656.0 KiB
#12 Time Exceeded ≥2090ms ≥1.574 MiB

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( i-p>=0 and j-p>=0)
				{
					int nw =0;
			   
			        for(int k=j+1;k<m;k++)
			        {
			       	     
			       	      
			    	     if(a[i][k]=='+') nw++;
			    	     else break;
			    	     if(nw>=p) break;
			        }

			    
                   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;
			        }

			        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;
			        }
			        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(nw<p) break;
			    
			        if(ans<((4LL*p)+1))
			        {
			        
				      

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

			 }
		}
	}

	cout<<max(ans,f)<<'\n';
}
int32_t main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
    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 09:13:38
Judged At
2024-12-09 09:13:38
Judged By
Score
20
Total Time
≥2098ms
Peak Memory
≥1.574 MiB