Submission #222000

# Submission time Handle Problem Language Result Execution time Memory
222000 2020-04-11T17:39:58 Z Haunted_Cpp Pohlepko (COCI16_pohlepko) C++17
50 / 80
1000 ms 22904 KB
/*
 author: Haunted_Cpp
 "Persistence guarantees that results are inevitable"
*/
 
#include <iostream>
#include <algorithm>
#include <vector>
 
#pragma GCC optimize ("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
using namespace std;

const int N = 2e3 + 5;
char g [N][N];

string coluna [N];
string linha [N], ant_linha [N];
  
int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int r, c;
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> g[i][j];
    }
  }
  coluna[0] = g[0][0];
  ant_linha[0] = g[0][0];
  for (int i = 1; i < c; i++) {
    ant_linha[i] = ant_linha[i - 1] + g[0][i];
  }
  for (int i = 1; i < r; i++) {
    coluna[i] = coluna[i - 1] + g[i][0];
  }
  for (int i = 1; i < r; i++) {
    for (int j = 1; j < c; j++) {
      string A = ant_linha[j];
      string B = (j == 1 ? coluna[i] : linha[j - 1]);
      linha[j] = min (A, B) + g[i][j];
    }
    for (int j = 1; j < c; j++) {
      ant_linha[j] = linha[j];
    }  
  }
  cout << linha[c - 1] << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Incorrect 5 ms 1792 KB Output isn't correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 10 ms 2176 KB Output is correct
6 Correct 164 ms 3452 KB Output is correct
7 Execution timed out 1093 ms 12536 KB Time limit exceeded
8 Execution timed out 1088 ms 22904 KB Time limit exceeded
9 Correct 7 ms 768 KB Output is correct
10 Correct 37 ms 1408 KB Output is correct
11 Correct 88 ms 3192 KB Output is correct
12 Correct 251 ms 5368 KB Output is correct
13 Correct 178 ms 9592 KB Output is correct
14 Execution timed out 1096 ms 22904 KB Time limit exceeded
15 Correct 12 ms 896 KB Output is correct
16 Execution timed out 1091 ms 13688 KB Time limit exceeded