This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
# define mkp make_pair
# define ff first
# define ss second
# define pll pair <ll, ll>
# define pii pair <int, int>
# define vec vector
# define pb push_back
# define pf push_front
# define ppb pop_back
# define ppf pop_front
# define all(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
# define sz(x) ((int)(x).size())
# define lb lower_bound
# define ub upper_bound
# define br break
# define rt return
# define cn continue
# define nl "\n"
# define off exit(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll MAXN = 3e5 + 25;
const ll MAXL = 18 + 0;
const ll INF1 = 1e18 + 0;
const ll INF2 = 2e9 + 0;
const ll MOD = 1e9 + 7;
const ll M0D = 998244353;
const ld PI = acos((ld) -1);
const ll P = 67 + 0 + 0;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
using namespace std;
ll n, m, cnt, ok;
char x[2025][2025];
bool used[2025][2025];
ll a, b, c, d;
void dfs (ll i, ll j)
{
if (used[i][j] || x[i][j] == '#') rt;
if (i < 1 || i > n || j < 1 || j > m)
{
ok = 0;
rt;
}
used[i][j] = 1; cnt++;
a = max(a, i + j); b = min(b, i + j);
c = max(c, i - j); d = min(d, i - j);
for (ll id = 0; id < 4; ++id)
{
dfs(i + dx[id], j + dy[id]);
}
}
void ma1n ()
{
cin >> n >> m;
for (ll i = 1; i <= n; ++i)
{
for (ll j = 1; j <= m; ++j)
{
cin >> x[i][j];
}
}
ll ans = 0;
for (ll i = 1; i <= n; ++i)
{
for (ll j = 1; j <= m; ++j)
{
if (x[i][j] == '#' || used[i][j]) cn;
a = -1e9, b = 1e9;
c = -1e9, d = 1e9;
ok = 1, cnt = 0;
dfs(i, j);
if (a - b == c - d)
{
if ((a - b) % 2 == 0)
{
if (ok)
{
ll nd = ((a - b) / 2 + 1);
if (cnt == 2 * nd * nd - 2 * nd + 1)
{
ans++;
}
}
}
}
}
}
cout << ans << nl;
}
int main (/*?*/)
{
int zxc = 1;
// cin >> zxc;
while (zxc--)
{
ma1n();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |