Submission #243464

# Submission time Handle Problem Language Result Execution time Memory
243464 2020-07-01T08:33:40 Z N1NT3NDO Pohlepko (COCI16_pohlepko) C++14
5 / 80
96 ms 19960 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back

using namespace std;

short n,m;
string s;
char c[2001][2001];
pair<short,short> dp[2001][2001];

void Rec(short i,short j)
{
  s+=c[i][j];
  if (i==0 && j==0)
    return;
  else Rec(dp[i][j].F,dp[i][j].S);
}

int main()
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n >> m;
  for(short i=0;i<n;i++)
    for(short j=0;j<m;j++) cin >> c[i][j];
  dp[0][0]={0,0};
  for(short i=0;i<n;i++)
    for(short j=0;j<m;j++)
          if (i-1>=0 && j-1>=0)
           {
             if (int(c[i][j])+int(c[i-1][j])<int(c[i][j])+int(c[i][j-1])) dp[i][j]={i-1,j};
             else dp[i][j]={i,j-1};
           }
        else if (i-1>=0 && j-1<0) dp[i][j]={i-1,j};
        else if (i-1<0 && j-1>=0) dp[i][j]={i,j-1};
  s+=c[n-1][m-1];
  Rec(dp[n-1][m-1].F,dp[n-1][m-1].S);
  reverse(s.begin(),s.end());
  cout << s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Correct 6 ms 3328 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Incorrect 5 ms 640 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Incorrect 11 ms 3328 KB Output isn't correct
7 Incorrect 38 ms 13432 KB Output isn't correct
8 Incorrect 94 ms 19936 KB Output isn't correct
9 Incorrect 5 ms 896 KB Output isn't correct
10 Incorrect 7 ms 1792 KB Output isn't correct
11 Incorrect 7 ms 1536 KB Output isn't correct
12 Incorrect 15 ms 7552 KB Output isn't correct
13 Incorrect 14 ms 13056 KB Output isn't correct
14 Incorrect 96 ms 19960 KB Output isn't correct
15 Incorrect 5 ms 1024 KB Output isn't correct
16 Incorrect 34 ms 15096 KB Output isn't correct