# 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;
void qataima ()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
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 (/*?*/)
{
qataima ();
int zxc = 1;
// cin >> zxc;
while (zxc--)
{
ma1n();
}
return 0;
}
Compilation message
Main.cpp: In function 'void qataima()':
Main.cpp:51:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:52:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |