Contest Duration: - (local time) (150 minutes) Back to Home

Submission #5269426

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int H, W;
string A[1010];
int vis[1010][1010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> H >> W;
rep(y, 0, H) cin >> A[y];

queue<pair<int, int>> que;
rep(y, 0, H) rep(x, 0, W) if (A[y][x] == '#') {
vis[y][x] = 1;
que.push({ x,y });
}

int ans = 0;
while (!que.empty()) {
queue<pair<int, int>> que2;

while (!que.empty()) {
int x, y;
tie(x, y) = que.front(); que.pop();

rep(d, 0, 4) {
int xx = x + dx[d];
int yy = y + dy[d];
if (xx < 0 or W <= xx or yy < 0 or H <= yy) continue;
if (!vis[yy][xx]) {
vis[yy][xx] = 1;
que2.push({ xx,yy });
}
}
}

swap(que2, que);
ans++;
}
cout << ans-1 << endl;
}

```

#### Submission Info

Submission Time 2019-05-04 23:59:27+0900 A - Darker and Darker hamayanhamayan C++14 (GCC 5.4.1) 300 2093 Byte AC 28 ms 13456 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
 AC × 2
 AC × 17
Set Name Test Cases
Sample sample01.txt, sample02.txt
All sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt AC 27 ms 7936 KB
in02.txt AC 28 ms 9344 KB
in03.txt AC 25 ms 10112 KB
in04.txt AC 25 ms 13456 KB
in05.txt AC 1 ms 256 KB
in06.txt AC 24 ms 5248 KB
in07.txt AC 25 ms 5248 KB
in08.txt AC 24 ms 5248 KB
in09.txt AC 24 ms 5248 KB
in10.txt AC 11 ms 2560 KB
in11.txt AC 10 ms 2304 KB
in12.txt AC 12 ms 4608 KB
in13.txt AC 12 ms 4480 KB
sample01.txt AC 1 ms 256 KB
sample02.txt AC 1 ms 256 KB