# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43331 | Hassoony | Pohlepko (COCI16_pohlepko) | C++14 | 1074 ms | 25328 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 long long ll;
const int MX=2009;
int n,m;
char a[MX][MX];
string ans[2][MX],s1,s2;
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)scanf("%s",&a[i]);
ans[0][m-1]=a[n-1][m-1];
for(int i=m-2;i>=0;i--)ans[0][i]=a[n-1][i]+ans[0][i+1];
// for(int i=0;i<m;i++)cout<<ans[0][i]<<endl;
for(int i=n-2;i>=0;i--){
for(int j=m-1;j>=0;j--){
if(j==m-1){
ans[1][j]=a[i][j]+a[0][j];
continue;
}
s1=a[i][j]+ans[0][j];
s2=a[i][j]+ans[1][j+1];
ans[1][j]=min(s1,s2);
}
swap(ans[0],ans[1]);
for(int j=0;j<MX;j++)ans[1][j]="";
}
cout<<ans[0][0]<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |