結果

問題 No.402 最も海から遠い場所
ユーザー CodeCreater123
提出日時 2024-11-14 22:59:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,281 bytes
コンパイル時間 3,985 ms
コンパイル使用メモリ 280,592 KB
実行使用メモリ 238,880 KB
最終ジャッジ日時 2024-11-14 23:00:23
合計ジャッジ時間 8,131 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

//
// 便
    
// ,
// .
// Code by ttq012.
// Date: 12/11/2024
#include <bits/stdc++.h>
#define eb emplace_back
#define int long long
using namespace std;
const int N = 1100110;
const int mod = 998244353;
const int base = 256;
const int inf = 0x0d000721ll << 2 | 0xAC66666;
namespace ttq012 {
int read() {
int o = 1, x = 0;
char ch;
while (!isdigit(ch = getchar())) {
if (ch == '-') {
o = -o;
}
}
x = ch & 15;
while (isdigit(ch = getchar())) {
x = (x << 3) + (x << 1) + (ch & 15);
}
return x * o;
}
int exgcd(int a, int b, int &x, int &y) {
if (!b) {
x = 1, y = 0;
return a;
}
int g, xp, yp;
g = exgcd(b, a % b, xp, yp);
x = yp, y = xp - yp * (a / b);
return g;
}
int ksm(int a, int b, int c) {
int ans = 1;
while (b) {
if (b & 1) {
ans = ans * a % c;
}
a = a * a % c;
b >>= 1;
}
return ans;
}
int Inv(int a, int Mod) {
return ksm(a, Mod - 2, Mod);
}
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
return a / gcd(a, b) * b;
}
void swap(int &a, int &b) {
a ^= b ^= a ^= b;
} } // using namespace ttq012;
namespace ttq012 {
char s[3010][3010];
int mp[2010][2010], X[3010], Y[3010], vis[2010][2010], dis[2010][2010];
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
void run() {
int n = read(), m = read();
for (int i = 1; i <= n; ++i) {
scanf("%s", s[i] + 1);
}
queue<pair<int, int>> q, qq;
for (int i = 0; i <= n + 1; ++i) {
for (int j = 0; j <= m + 1; ++j) {
if (!i || !j || i == n + 1 || j == m + 1 || s[i][j] == '.') {
q.emplace(i, j);
dis[i][j] = 1;
}
}
}
int mx = 0, dep = 0;
while (q.size()) {
q.swap(qq);
while (qq.size()) {
mx = max(mx, dep);
auto t = qq.front() ; qq.pop();
for (int dx = -1; dx <= 1; ++dx) {
for (int dy = -1; dy <= 1; ++dy) {
if (dx || dy) {
int i = t.first + dx, j = t.second + dy;
if (i < 0 || j < 0 || i > n + 1 || j > m + 1) {
continue;
}
if (!vis[i][j]) {
vis[i][j] = 1;
q.emplace(i, j);
}
}
}
}
}
++dep;
}
cout << mx << '\n';
} }
signed main() {
ttq012::run();
return 0;
}
/*
*/
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0