Submission #785949

# Submission time Handle Problem Language Result Execution time Memory
785949 2023-07-17T20:05:29 Z MilosMilutinovic Rima (COCI17_rima) C++14
14 / 140
1000 ms 18016 KB
/**
 *    author:  wxhtzdy
 *    created: 17.07.2023 22:01:28
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  auto Check = [&](string s, string t) {
    int ptr = 0;
    int si = (int) s.size();
    int sj = (int) t.size();
    while (ptr < min(si, sj) && s[si - ptr - 1] == t[sj - ptr - 1]) {
      ptr += 1;
    }     
    return (ptr >= max(si, sj) - 1);
  };
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++) {
      if (Check(s[i], s[j])) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << '\n';                   
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Execution timed out 1093 ms 18016 KB Time limit exceeded
5 Execution timed out 1081 ms 3452 KB Time limit exceeded
6 Incorrect 202 ms 1316 KB Output isn't correct
7 Incorrect 113 ms 1140 KB Output isn't correct
8 Incorrect 59 ms 1076 KB Output isn't correct
9 Execution timed out 1092 ms 4044 KB Time limit exceeded
10 Incorrect 68 ms 1156 KB Output isn't correct