# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43341 | 2018-03-13T19:45:09 Z | Hassoony | Pohlepko (COCI16_pohlepko) | C++14 | 1000 ms | 14812 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX=2001; int n,m; char a[MX][MX]; string ans[2][MX],s1; int main(){ scanf("%d%d",&n,&m); for(int i=0;i<n;i++)scanf("%s",&a[i]); if(m==1){ for(int i=0;i<n;i++)s1+=a[i][0]; cout<<s1<<endl; return 0; } if(n==1){ for(int i=0;i<m;i++)s1+=a[0][i]; cout<<s1<<endl; return 0; } 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=n-2;i>=0;i--){ for(int j=m-1;j>=0;j--){ if(j==m-1){ ans[1][j]=a[i][j]+ans[0][j]; ans[0][j]=ans[1][j]; continue; } ans[1][j]=min(a[i][j]+ans[0][j],a[i][j]+ans[1][j+1]); ans[0][j]=ans[1][j]; ans[1][j+1]=""; } ans[1][0]=""; } cout<<ans[0][0]<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 1508 KB | Output is correct |
3 | Correct | 2 ms | 1508 KB | Output is correct |
4 | Correct | 2 ms | 1508 KB | Output is correct |
5 | Correct | 6 ms | 2152 KB | Output is correct |
6 | Correct | 112 ms | 2564 KB | Output is correct |
7 | Correct | 749 ms | 8808 KB | Output is correct |
8 | Execution timed out | 1064 ms | 14512 KB | Time limit exceeded |
9 | Correct | 3 ms | 14512 KB | Output is correct |
10 | Correct | 25 ms | 14512 KB | Output is correct |
11 | Correct | 60 ms | 14512 KB | Output is correct |
12 | Correct | 165 ms | 14512 KB | Output is correct |
13 | Correct | 106 ms | 14512 KB | Output is correct |
14 | Execution timed out | 1065 ms | 14812 KB | Time limit exceeded |
15 | Correct | 7 ms | 14812 KB | Output is correct |
16 | Execution timed out | 1029 ms | 14812 KB | Time limit exceeded |