Submission #43333

# Submission time Handle Problem Language Result Execution time Memory
43333 2018-03-13T19:36:36 Z Hassoony Pohlepko (COCI16_pohlepko) C++14
50 / 80
1000 ms 15028 KB
#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]);
    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=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

pohlepko.cpp: In function 'int main()':
pohlepko.cpp:11:41: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[2009]' [-Wformat=]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                         ^
pohlepko.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
pohlepko.cpp:11:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                          ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 1504 KB Output is correct
3 Correct 2 ms 1504 KB Output is correct
4 Correct 3 ms 1504 KB Output is correct
5 Correct 6 ms 2140 KB Output is correct
6 Correct 116 ms 2652 KB Output is correct
7 Incorrect 710 ms 8664 KB Output isn't correct
8 Execution timed out 1070 ms 14948 KB Time limit exceeded
9 Incorrect 15 ms 14948 KB Output isn't correct
10 Correct 50 ms 14948 KB Output is correct
11 Correct 59 ms 14948 KB Output is correct
12 Incorrect 185 ms 14948 KB Output isn't correct
13 Incorrect 149 ms 14948 KB Output isn't correct
14 Execution timed out 1086 ms 15028 KB Time limit exceeded
15 Correct 8 ms 15028 KB Output is correct
16 Correct 974 ms 15028 KB Output is correct