/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 500.0 KiB
#2 Accepted 10ms 332.0 KiB
#3 Accepted 99ms 560.0 KiB
#4 Accepted 111ms 328.0 KiB
#5 Accepted 24ms 328.0 KiB
#6 Accepted 164ms 568.0 KiB
#7 Accepted 1283ms 560.0 KiB
#8 Accepted 35ms 540.0 KiB
#9 Accepted 35ms 584.0 KiB
#10 Accepted 33ms 656.0 KiB
#11 Time Exceeded ≥2082ms ≥652.0 KiB
#12 Time Exceeded ≥2067ms ≥1.496 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(true and 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(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;
			        }

			        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(p==2)
			        // {
			        // 	cout<<i<<' '<<j<<endl;
			        // }
			        if(ans<((4LL*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;
}

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:54:07
Judged At
2024-12-09 08:54:07
Judged By
Score
20
Total Time
≥2082ms
Peak Memory
≥1.496 MiB