| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 856951 | teesla | Tracks in the Snow (BOI13_tracks) | C++14 | 2106 ms | 148136 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4005;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
int adj[maxn][maxn], vis[maxn][maxn];
int vx[4] = {0,1,0,-1}, vy[4] = {1,0,-1,0};
int h,w;
int dijkstra(){
priority_queue<iii, vector<iii> , greater<iii>> q;
vis[h][w] = 1;
q.push({1,{h,w}});
int maior = 1;
while(!q.empty()){
auto [a,b] = q.top();
auto [x,y] = b;
q.pop();
if(vis[x][y] < a) continue;
maior = max(maior, a);
for(int i=0; i<4; i++){
int xx = x + vx[i], yy = y + vy[i];
if(adj[xx][yy] == 0) continue;
int val = a;
if(adj[x][y] != adj[xx][yy]) val += 1;
if(vis[xx][yy] != 0 and vis[xx][yy] <= val) continue;
vis[xx][yy] = val;
q.push({val, {xx,yy}});
}
}
return maior;
}
int main(){
cin >> h >> w;
for(int i=1; i<=h; i++){
string s; cin >> s;
for(int j =0; j<w; j++){
int val = 0;
if(s[j] == 'R') val = 1;
else if(s[j] == 'F') val = 2;
adj[i][j+1] = val;
}
}
cout << dijkstra() << endl;
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
