Submission #5263259
Source Code Expand
#include<iostream>
#include<queue>
#include<map>
using namespace std;
int d[1001][1001];
int INF = 1e9;
int main(){
queue<pair<int,pair<int, int> > > q;
int H,W;
cin >> H >> W;
for (int i=0;i<H;i++){
for (int j=0;j<W;j++){
d[i][j] = INF;
}
}
string s;
for(int i=0;i<H;i++){
cin >> s;
for(int j=0;j<W;j++){
if(s[j] == '#'){
d[i][j] = 0;
q.push(make_pair(0,make_pair(i,j)));
}
}
}
while(!q.empty()){
pair<int,pair<int, int> > a = q.front();
q.pop();
int dv = a.first;
int x = a.second.first;
int y = a.second.second;
int dx = 1;
int dy = 0;
for (int j=0;j<4;j++){
int t = dx;
dx = dy;
dy = -t;
int xx = x + dx;
int yy = y + dy;
if (xx == -1 | xx == H){
continue;
}
if (yy == -1 | yy == W){
continue;
}
if (d[xx][yy] == INF){
d[xx][yy] = dv + 1;
q.push(make_pair(dv+1,make_pair(xx,yy)));
}
}
}
int ans = 0;
for (int i=0;i<H;i++){
for (int j=0;j<W;j++){
if (ans < d[i][j]){
ans = d[i][j];
}
}
}
cout << ans << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Darker and Darker |
| User | maspy |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 1224 Byte |
| Status | AC |
| Exec Time | 60 ms |
| Memory | 16272 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 57 ms | 8064 KiB |
| in02.txt | AC | 60 ms | 10368 KiB |
| in03.txt | AC | 53 ms | 11536 KiB |
| in04.txt | AC | 58 ms | 16272 KiB |
| in05.txt | AC | 1 ms | 256 KiB |
| in06.txt | AC | 58 ms | 4224 KiB |
| in07.txt | AC | 54 ms | 4224 KiB |
| in08.txt | AC | 54 ms | 4224 KiB |
| in09.txt | AC | 55 ms | 4224 KiB |
| in10.txt | AC | 24 ms | 2048 KiB |
| in11.txt | AC | 22 ms | 1920 KiB |
| in12.txt | AC | 24 ms | 4096 KiB |
| in13.txt | AC | 24 ms | 3968 KiB |
| sample01.txt | AC | 1 ms | 256 KiB |
| sample02.txt | AC | 1 ms | 256 KiB |