/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Runtime Error 3ms 796.0 KiB
#3 Runtime Error 2ms 796.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define bug(a) cout << #a << " : " << a << endl;

void solve(){
	
	int n, m; cin >> n >> m;
	char s[n + 5][m + 5];
	int l [n + 5][m + 5];
	int r [n + 5][m + 5];
	int t [n + 5][m + 5];
	int b [n + 5][m + 5];

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		int cnt = 0;
		for(int j = 1; j <= m; j++){
			l[i][j] = cnt;
			if(s[i][j] == '+'){
				cnt++;
			}
			else{
				cnt = 0;
			}
		}
		cnt = 0;
		for(int j = m; j > 0; j--){
			r[i][j] = cnt;
			if(s[i][j] == '+'){
				cnt++;
			}
			else{
				cnt = 0;
			}
		}
	}
	for(int j = 1; j <= m; j++){
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			t[i][j]= cnt;
			if(s[i][j]== '+'){
				cnt++;
			}
			else{
				cnt = 0;
			}
		}
		cnt = 0;
		for(int i = m; i > 0; i--){
			b[i][j]= cnt;
			if(s[i][j]== '+'){
				cnt++;
			}
			else{
				cnt = 0;
			}
		}
	}
	ll mx = 0;
	// for(int i = 1; i <= n; i++){
	// 	for(int j = 1; j <= m; j++){
	// 		cout << l[i][j] << ' ' << r[i][j] << ' ' << t[i][j] << ' ' << b[i][j] << endl;
	// 	}
	// 	cout << endl;
	// }	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '+'){
				int tmp = min({l[i][j], r[i][j], t[i][j], b[i][j]});
				mx = max(mx, (1LL * 4 * tmp) + 1);
			}
		}
	}

	cout << mx << '\n';

}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int tc = 1, cs = 0;
	cin >> tc;

	while(tc--){
		//cout << "Case # " << ++cs << ": " ;
		solve();
	}

}

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 05:48:50
Judged At
2024-12-09 05:48:50
Judged By
Score
2
Total Time
3ms
Peak Memory
796.0 KiB