# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
720682 | Yell0 | Pohlepko (COCI16_pohlepko) | C++17 | 86 ms | 8124 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |