結果

問題 No.962 LCPs
ユーザー lumc_lumc_
提出日時 2019-12-22 18:01:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,332 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 106,404 KB
実行使用メモリ 13,928 KB
最終ジャッジ日時 2023-10-12 14:35:07
合計ジャッジ時間 5,321 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,324 KB
testcase_01 AC 4 ms
7,724 KB
testcase_02 AC 6 ms
7,708 KB
testcase_03 AC 4 ms
7,792 KB
testcase_04 AC 4 ms
7,644 KB
testcase_05 AC 5 ms
7,712 KB
testcase_06 AC 5 ms
7,712 KB
testcase_07 AC 5 ms
7,916 KB
testcase_08 AC 5 ms
7,720 KB
testcase_09 AC 4 ms
7,648 KB
testcase_10 AC 5 ms
7,668 KB
testcase_11 AC 4 ms
7,664 KB
testcase_12 AC 5 ms
7,772 KB
testcase_13 AC 5 ms
7,796 KB
testcase_14 AC 4 ms
7,660 KB
testcase_15 AC 5 ms
7,720 KB
testcase_16 AC 4 ms
7,720 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// TLE
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  string t;
  cin >> t;
  const int S = 2e5;
  assert(1 <= t.size() && t.size() <= S);
  for(auto c : t) assert('a' <= c && c <= 'z');
  vector<vector<int>> cnt(S + 1);
  ll ans = t.size();
  assert(ans <= S);

  for(int i = 1; i < n; i++) {
    string s;
    cin >> s;
    for(auto c : s) assert('a' <= c && c <= 'z');
    assert(1 <= s.size() && s.size() <= S);
    int f = 0;
    while(f < s.size() && f < t.size() && s[f] == t[f]) f++;
    t = s;
    cnt.at(f).push_back(i);
    ans += s.size();
    assert(ans <= S);
  }
  vector<int> used(n+1);
  used[0] = used[n] = 1;
  for(int i = 0; i <= S; i++) {
    for(int j : cnt[i]) {
      ll x = 1;
      while(!used[j-x]) x++;
      ll y = 1;
      while(!used[j+y]) y++;
      ans += ((x * x * y + x * y * y) / 2 + x * y) * i;
      used[j] = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
0