| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1322359 | alexandros | Tracks in the Snow (BOI13_tracks) | C++20 | 1108 ms | 269680 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<int>> vec;
deque<pair<ll, ll>> dq;
vector<vector<ll>> dist;
int main()
{
ll width, height;
char cur;
scanf("%lld %lld", &height, &width);
vec.assign(height, vector<int>(width, 0));
for(ll i = 0; i < height; i++)
{
for(ll j = 0; j < width; j++)
{
scanf(" %c", &cur);
if(cur == 'R')
{
vec[i][j] = 1;
}
else if(cur == 'F')
{
vec[i][j] = 2;
}
}
}
dist.assign(height, vector<ll>(width, -1));
dq.push_back({0, 0});
dist[0][0] = 1;
pair<ll, ll> tp;
ll big = 1;
while(!dq.empty())
{
tp = dq.front();
dq.pop_front();
for(ll i = -1; i <= 1; i++)
{
for(ll j = -1; j <= 1; j++)
{
if(i != 0 && j != 0) continue;
if(i == 0 && j == 0) continue;
ll ni = tp.first + i;
ll nj = tp.second + j;
if(ni < 0 || nj < 0) continue;
if(ni >= height || nj >= width) continue;
if(dist[ni][nj] != -1) continue;
if(vec[ni][nj] == 0) continue;
dist[ni][nj] = dist[tp.first][tp.second];
if(vec[ni][nj] == vec[tp.first][tp.second]) dq.push_front({ni, nj});
else
{
dq.push_back({ni, nj});
dist[ni][nj]++;
}
big = max(big, dist[ni][nj]);
}
}
}
printf("%lld", big);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
