# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
533954 | AaronJ | Tracks in the Snow (BOI13_tracks) | C++98 | 943 ms | 220784 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
const int N = 2e5 + 5, MOD = 1e9 + 7, INF = 1e9;
#define X first
#define Y second
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
int n, m; cin >> n >> m;
vector<vector<int>> dis(n, vector<int>(m, INF));
vector<vector<char>> c(n, (vector<char>(m)));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> c[i][j];
}
}
deque<pair<int, int>> dq;
int ans = 0;
dq.push_back({0, 0});
dis[0][0] = 1;
auto check = [&](int i, int j, int x, int y){
if(c[i][j] == '.' || dis[i][j] != INF) return;
if(c[i][j] == c[x][y]) dis[i][j] = dis[x][y], dq.push_front({i, j});
else dis[i][j] = dis[x][y] + 1, dq.push_back({i, j});
};
while(dq.size()){
auto i = dq.front(); dq.pop_front();
int I = i.X, J = i.Y;
if(I < n - 1) check(I + 1, J, I, J);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |