Time Exceeded
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define vii vector<ll>
#define pll pair<ll, ll>
#define F first
#define S second
const ll N = (ll) 3e5 + 5;
const ll mod = (ll) 1e9 + 7;
const ll inf = (ll) 1e18;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--) {
ll a, b, c, i, j, k, m, n, o, x, y, z;
cin >> n >> m;
vector<vector<char>> s(n, vector<char>(m));
for(i = 0; i < n; i++) {
for(j = 0; j < m; j++) {
cin >> s[i][j];
}
}
ll ans = 0;
for(i = 0; i < n; i++) {
for(j = 0; j < m; j++) {
if(s[i][j] == '+') {
ll mn = n + m + 1;
ll jj = j;
while(jj < m && s[i][jj] == '+') {
jj++;
}
mn = min(mn, jj - j);
jj = j;
while(jj >= 0 && s[i][jj] == '+') {
jj--;
}
mn = min(mn, j - jj);
ll ii = i;
while(ii < n && s[ii][j] == '+') {
ii++;
}
mn = min(mn, ii - i);
ii = i;
while(ii >= 0 && s[ii][j] == '+') {
ii--;
}
mn = min(mn, i - ii);
ans = max(ans, mn);
}
}
}
cout << (ans == 0 ? 0 : (ans << 2) - 3) << "\n";
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1143 Plus of Pluses
- Contest
- LU Divisonal Contest Problem Testing Round
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-12-08 03:18:39
- Judged At
- 2024-12-08 03:18:39
- Judged By
- Score
- 44
- Total Time
- ≥2059ms
- Peak Memory
- ≥1.535 MiB