/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 14ms 332.0 KiB
#3 Accepted 99ms 328.0 KiB
#4 Accepted 105ms 336.0 KiB
#5 Accepted 55ms 332.0 KiB
#6 Accepted 122ms 328.0 KiB
#7 Accepted 597ms 332.0 KiB
#8 Accepted 44ms 332.0 KiB
#9 Accepted 49ms 768.0 KiB
#10 Accepted 46ms 652.0 KiB
#11 Accepted 1854ms 652.0 KiB
#12 Time Exceeded ≥2092ms ≥1.277 MiB
#13 Accepted 107ms 1.277 MiB
#14 Accepted 14ms 1.547 MiB
#15 Accepted 21ms 1.648 MiB
#16 Accepted 15ms 1.723 MiB
#17 Wrong Answer 15ms 1.527 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 = 100;
    			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) break;
    				}
    				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) break;
    				}
    				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) break;
    				}
    				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) break;
    				}
    				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:33:54
Judged At
2024-12-14 12:33:54
Judged By
Score
40
Total Time
≥2092ms
Peak Memory
≥1.723 MiB