# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
870687 | Servant_of_the_Lord | Tracks in the Snow (BOI13_tracks) | C++17 | 804 ms | 54556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll x,y,z,a,b,c;
cin>>x>>y;
vector<string>v;
vector<vector<bool>>w;
for(ll i=0;i<x;i++)w.push_back(vector<bool>(y));
for(ll i=0;i<x;i++)
{
string s;
cin>>s;
v.push_back(s);
}
queue<pair<ll,ll>>q,r;
q.push({0,0});
a=0;
function<void(ll,ll,ll,ll)>add=[&](ll a,ll b,ll c,ll d)
{
if(a>=0&&a<x&&b>=0&&b<y&&!w[a][b])
{
w[a][b]=true;
if(v[a][b]==v[c][d])q.push({a,b});
else if(v[a][b]!='.')r.push({a,b});
}
};
while(q.size())
{
a++;
while(q.size())
{
pair<ll,ll>p=q.front();
add(p.first-1,p.second,p.first,p.second);
add(p.first+1,p.second,p.first,p.second);
add(p.first,p.second-1,p.first,p.second);
add(p.first,p.second+1,p.first,p.second);
q.pop();
}
q.swap(r);
}
cout<<a<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |