Submission #43340

# Submission time Handle Problem Language Result Execution time Memory
43340 2018-03-13T19:44:32 Z Hassoony Pohlepko (COCI16_pohlepko) C++14
Compilation error
0 ms 0 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];
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

pohlepko.cpp: In function 'int main()':
pohlepko.cpp:11:41: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[2001]' [-Wformat=]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                         ^
pohlepko.cpp:13:29: error: 's1' was not declared in this scope
         for(int i=0;i<n;i++)s1+=a[i][0];
                             ^
pohlepko.cpp:14:15: error: 's1' was not declared in this scope
         cout<<s1<<endl;
               ^
pohlepko.cpp:18:29: error: 's1' was not declared in this scope
         for(int i=0;i<m;i++)s1+=a[0][i];
                             ^
pohlepko.cpp:19:15: error: 's1' was not declared in this scope
         cout<<s1<<endl;
               ^
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]);
                                          ^