Submission #925175

# Submission time Handle Problem Language Result Execution time Memory
925175 2024-02-10T23:32:04 Z jpfr12 Pohlepko (COCI16_pohlepko) C++17
10 / 80
38 ms 40040 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
 
typedef long long ll;
typedef unsigned long long int ull;
using namespace std;
int MOD = (int)1e9+7;
int MAXN = 1e6;
 
//classes

 
 
//global


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ifstream fin("teamwork.in");
  //ofstream fout("teamwork.out");
  //stop
  int n, m;
  cin >> n >> m;
  vector<string> vec(n);
  for(string& i: vec) cin >> i;
  vector<vector<pair<int,int>>> dp(n, vector<pair<int,int>>(m));
  dp[0][0] = make_pair(-1,-1);
  //first row
  for(int i = 1; i < m; i++){
    dp[0][i] = make_pair(0, i-1);
  }
  //first col
  for(int i = 1; i < n; i++){
    dp[i][0] = make_pair(i-1, 0);
  }
  for(int i = 1; i < n; i++){
    for(int j = 1; j < m; j++){
      if(vec[i-1][j] < vec[i][j-1]) dp[i][j] = make_pair(i-1, j);
      else dp[i][j] = make_pair(i, j-1);
    }
  }
  string ans = "";
  pair<int,int> p = {n-1, m-1};
  while(p.first >= 0 && p.second >= 0){
    ans += vec[p.first][p.second];
    p = dp[p.first][p.second];
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
  return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 460 KB Output isn't correct
6 Incorrect 3 ms 2652 KB Output isn't correct
7 Incorrect 13 ms 13660 KB Output isn't correct
8 Incorrect 38 ms 39844 KB Output isn't correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Incorrect 1 ms 1236 KB Output isn't correct
11 Incorrect 2 ms 1616 KB Output isn't correct
12 Incorrect 4 ms 3676 KB Output isn't correct
13 Incorrect 3 ms 2520 KB Output isn't correct
14 Incorrect 38 ms 40040 KB Output isn't correct
15 Incorrect 1 ms 604 KB Output isn't correct
16 Incorrect 9 ms 15904 KB Output isn't correct