# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1109563 | Zero_OP | Pohlepko (COCI16_pohlepko) | C++14 | 58 ms | 21320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, M;
cin >> N >> M;
vector<vector<char>> a(N, vector<char>(M));
for(int i = 0; i < N; ++i){
for(int j = 0; j < M; ++j){
cin >> a[i][j];
}
}
vector<vector<int>> par(N, vector<int>(M, -1));
//0 : (-1, 0)
//1 : (0, -1)
queue<tuple<int, int, int>> q;
q.push({0, 0, 0});
const int dx[2] = {0, 1};
const int dy[2] = {1, 0};
vector<pair<int, int>> cand;
cand.push_back({0, 0});
while(!cand.empty()){
vector<pair<int, int>> new_cand;
cout << a[cand[0].first][cand[0].second];
if(cand[0] == make_pair(N - 1, M - 1)){
break;
}
int best = -1;
for(auto [x, y] : cand){
for(int i = 0; i < 2; ++i){
int nx = x + dx[i], ny = y + dy[i];
if(nx < N && ny < M){
int c = a[nx][ny] - 'a';
if(best == -1 || best > c){
best = c;
new_cand.clear();
new_cand.emplace_back(nx, ny);
} else if(best == c) new_cand.emplace_back(nx, ny);
}
}
}
sort(new_cand.begin(), new_cand.end());
new_cand.erase(unique(new_cand.begin(), new_cand.end()), new_cand.end());
swap(cand, new_cand);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |