# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
441338 | WindChaser | Tracks in the Snow (BOI13_tracks) | C++11 | 602 ms | 118736 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
void setIO(string name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
if(name.size()){
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
//tracks in the Snow
int h, w;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
string snow[4000];
int numAni[4000][4000];
bool valid(int x, int y)
{
return (x > -1 && x < h && y > -1 && y < w && snow[x][y] != '.');
}
int main()
{
setIO();
cin >> h >> w;
for(int i = 0; i < h; i++)
{
cin >> snow[i];
}
deque<pair<int, int>> q;
q.push_back({0,0});
numAni[0][0] = 1;
int ans = 1;
while(!q.empty())
{
pair<int, int> c = q.front();
q.pop_front();
int curAni = numAni[c.first][c.second];
ans = max(ans, curAni);
for(int i = 0; i < 4; i++)
{
int nx = c.first + dx[i];
int ny = c.second + dy[i];
if(valid(nx, ny) && numAni[nx][ny] == 0)
{
if(snow[nx][ny] == snow[c.first][c.second])
{
numAni[nx][ny] = curAni;
q.push_front({nx,ny});
}
else
{
numAni[nx][ny] = curAni + 1;
q.push_back({nx,ny});
}
}
}
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |