# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26489 | samir_droubi | Tracks in the Snow (BOI13_tracks) | C++14 | 1416 ms | 838424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxn=4005;
char g[mxn][mxn];
int n,m;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
bool check(int x,int y)
{
return x>=0&&x<n&&y>=0&&y<m&&g[x][y]!='*';
}
char ty;
int c=0;
vector<pair<int,int> >v;
vector<pair<int,int> >vv;
queue<pair<int,int> >q;
void bfs()
{
while(!q.empty())
{
int x=q.front().first;
int y=q.front().second;
++c;
q.pop();
for(int i=0;i<4;++i)
{
int xx=x+dx[i];
int yy=y+dy[i];
if(!check(xx,yy))continue;
if(g[xx][yy]!=ty)
{
vv.push_back({xx,yy});
continue;
}
q.push({xx,yy});
g[xx][yy]='.';
}
}
}
int main()
{
scanf("%d%d",&n,&m);
int cnt=n*m;
for(int i=0;i<n;++i)scanf("%s",&g[i]);
for(int i=0;i<n;++i)
{
for(int j=0;j<m;++j)
if(g[i][j]=='.')
--cnt;
}
v.push_back({0,0});
int ans=0;
while(c!=cnt)
{
for(int i=0;i<v.size();++i)
{
int x=v[i].first;
int y=v[i].second;
if(g[x][y]=='.')continue;
ty=g[x][y];
g[x][y]='.';
q.push({x,y});
bfs();
}
v=vv;
vv.clear();
++ans;
}
printf("%d\n",ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |