/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 8.777 MiB
#2 Accepted 14ms 10.777 MiB
#3 Accepted 9ms 10.816 MiB
#4 Accepted 10ms 12.777 MiB
#5 Accepted 11ms 12.809 MiB
#6 Accepted 9ms 11.004 MiB
#7 Accepted 23ms 13.02 MiB
#8 Accepted 44ms 13.02 MiB
#9 Accepted 47ms 26.973 MiB
#10 Accepted 46ms 17.746 MiB
#11 Accepted 25ms 16.52 MiB
#12 Accepted 35ms 42.285 MiB
#13 Accepted 35ms 41.809 MiB
#14 Accepted 33ms 43.559 MiB
#15 Accepted 36ms 42.055 MiB
#16 Accepted 36ms 40.555 MiB
#17 Accepted 37ms 40.668 MiB
#18 Accepted 37ms 40.52 MiB
#19 Accepted 41ms 41.09 MiB
#20 Accepted 37ms 40.77 MiB
#21 Accepted 116ms 66.02 MiB
#22 Accepted 115ms 66.02 MiB
#23 Accepted 125ms 66.047 MiB
#24 Accepted 164ms 65.852 MiB
#25 Accepted 301ms 65.75 MiB
#26 Accepted 215ms 65.621 MiB
#27 Accepted 243ms 65.863 MiB
#28 Accepted 241ms 65.734 MiB
#29 Accepted 232ms 65.852 MiB
#30 Accepted 209ms 65.875 MiB

Code

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

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

const int N = 2e3 + 10;
char s[N][N];
int l[N][N], r[N][N], t[N][N], b[N][N];

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 = n; 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:55:21
Judged At
2024-12-09 05:55:21
Judged By
Score
100
Total Time
301ms
Peak Memory
66.047 MiB