# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
720682 | Yell0 | Pohlepko (COCI16_pohlepko) | C++17 | 86 ms | 8124 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MN=2002;
int N,M;
char grid[MN][MN];
set<pii> ol,nl;
string ans="";
int main() {
ios::sync_with_stdio(0);cin.tie(0);
cin>>N>>M;
string in;
for(int i=1;i<=N;i++) {
cin>>in;
for(int j=1;j<=M;j++)
grid[i][j]=in[j-1];
}
ol.insert({1,1});
ans+=grid[1][1];
for(int i=1;i<N+M-1;i++) {
char opt='|';
for(pii p:ol) {
char d=grid[p.first+1][p.second],r=grid[p.first][p.second+1];
if(p.first+1<=N) {
if(d<opt) {
opt=d;
nl.clear();
nl.insert({p.first+1,p.second});
} else if(d==opt) nl.insert({p.first+1,p.second});
}
if(p.second+1<=M) {
if(r<opt) {
opt=r;
nl.clear();
nl.insert({p.first,p.second+1});
} else if(r==opt) nl.insert({p.first,p.second+1});
}
}
ans+=opt;
ol=nl;
nl.clear();
}
cout<<ans<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |