/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 11ms 328.0 KiB
#3 Accepted 133ms 540.0 KiB
#4 Accepted 151ms 576.0 KiB
#5 Accepted 73ms 540.0 KiB
#6 Accepted 162ms 560.0 KiB
#7 Accepted 848ms 588.0 KiB
#8 Accepted 37ms 772.0 KiB
#9 Accepted 36ms 796.0 KiB
#10 Accepted 36ms 540.0 KiB
#11 Time Exceeded ≥2097ms ≥796.0 KiB
#12 Time Exceeded ≥2098ms ≥1.277 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int long long
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 p = 0;
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<m;j++)
    	{
    		if(a[i][j]=='+')
    		{
    			// cout<<a[i][j]<<' ';
    			p = 1;
    			int l = 1, r = 512;
    			while(l<=r)
    			{
    				int mid = (l+r)/2;
    				int cnt =0;
    				for(int k=j-1;k>=0;k--)
    				{
    					if(a[i][k]!='+') break;
    					else cnt++;
    				}
    				if(cnt<mid) 
    				{
    					r = mid-1;
    					continue;
    				}
    				cnt = 0;
    				for(int k=j+1;k<m;k++)
    				{
    					if(a[i][k]!='+') break;
    					else cnt++;
    				}
    				if(cnt<mid) 
    				{
    					r = mid-1;
    					continue;
    				}
    				cnt = 0;
    				for(int k=i-1;k>=0;k--)
    				{
    					if(a[k][j]!='+') break;
    					else cnt++; 
    				}
    				if(cnt<mid) 
    				{
    					r = mid-1;
    					continue;
    				}
    				cnt = 0;
    				for(int k=i+1;k<n;k++)
    				{
    					if(a[k][j]!='+') break;
    					else cnt++; 
    				}
    				if(cnt<mid) 
    				{
    					r = mid-1;
    					continue;
    				}
    				l = mid+1;
    				int nw = (4LL*mid) + 1;
    				ans = max(ans,nw);


    			}
    		}
    	}
    }
    cout<<max(ans,p)<<endl;
}
int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc;
    cin>>tc;
    while(tc--)
    {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-14 12:19:51
Judged At
2024-12-14 12:19:51
Judged By
Score
20
Total Time
≥2098ms
Peak Memory
≥1.277 MiB