# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
438498 | zeyu | Tracks in the Snow (BOI13_tracks) | C++17 | 985 ms | 110424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
char graph[n][m];
for (int i = 0; i < n; i ++) for (int j = 0; j < m; j ++) cin >> graph[i][j];
int cnt[n][m];
int inf = 0x3f3f3f3f;
memset(cnt, inf, sizeof(cnt));
cnt[0][0] = 1;
deque<pair<int, int> > que;
que.push_front(make_pair(0, 0));
while(! que.empty()){
pair<int, int> p = que.front();
que.pop_front();
for (int i = 0; i < 4; i ++){
int x = p.first + dx[i];
int y = p.second + dy[i];
if (x >= 0 && x < n && y >= 0 && y < m && cnt[x][y] > cnt[p.first][p.second] + (graph[x][y] != graph[p.first][p.second]) && (graph[x][y] == 'R' || graph[x][y] == 'F')){
if (graph[x][y] != graph[p.first][p.second]){
cnt[x][y] = cnt[p.first][p.second] + 1;
que.push_back(make_pair(x, y));
} else{
cnt[x][y] = cnt[p.first][p.second];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |