# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
866328 | gutzzy | Pohlepko (COCI16_pohlepko) | C++14 | 150 ms | 8228 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
int m;
vector<vector<char>> board;
int main(){
cin >> n >> m;
board = vector<vector<char>>(n,vector<char>(m));
queue<pair<int,int>> q;
string ans="";
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin >> board[i][j];
}
}
q.push({0,0});
ans+=board[0][0];
for(int diagonal=0;diagonal<(m+n-2);diagonal++){
char best='{';
set<pair<int,int>> coords;
while(!q.empty()){
pair<int,int> p = q.front();
q.pop();
int i=p.first;
int j=p.second;
if(i!=n-1){
if(board[i+1][j]<=best){
best=board[i+1][j];
coords.insert({i+1,j});
}
}
if(j!=m-1){
if(board[i][j+1]<=best){
best=board[i][j+1];
coords.insert({i,j+1});
}
}
}
ans+=best;
for(auto coord:coords){
if (board[coord.first][coord.second]==best){
q.push(coord);
}
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |