結果

問題 No.962 LCPs
ユーザー 👑 emthrmemthrm
提出日時 2019-12-24 23:21:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,664 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 136,568 KB
実行使用メモリ 32,776 KB
最終ジャッジ日時 2023-10-23 22:08:52
合計ジャッジ時間 13,076 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
16,128 KB
testcase_01 AC 64 ms
16,128 KB
testcase_02 AC 65 ms
16,216 KB
testcase_03 AC 65 ms
16,172 KB
testcase_04 AC 65 ms
16,160 KB
testcase_05 AC 64 ms
16,156 KB
testcase_06 AC 64 ms
16,152 KB
testcase_07 AC 64 ms
16,160 KB
testcase_08 AC 65 ms
16,164 KB
testcase_09 AC 64 ms
16,156 KB
testcase_10 AC 64 ms
16,160 KB
testcase_11 AC 65 ms
16,148 KB
testcase_12 AC 64 ms
16,136 KB
testcase_13 AC 64 ms
16,132 KB
testcase_14 AC 64 ms
16,136 KB
testcase_15 AC 65 ms
16,128 KB
testcase_16 AC 64 ms
16,136 KB
testcase_17 AC 153 ms
32,776 KB
testcase_18 AC 135 ms
24,324 KB
testcase_19 AC 135 ms
24,324 KB
testcase_20 AC 127 ms
21,420 KB
testcase_21 AC 126 ms
21,420 KB
testcase_22 AC 119 ms
20,892 KB
testcase_23 AC 118 ms
20,892 KB
testcase_24 AC 115 ms
19,836 KB
testcase_25 AC 113 ms
19,836 KB
testcase_26 AC 111 ms
19,572 KB
testcase_27 AC 121 ms
21,156 KB
testcase_28 AC 111 ms
19,572 KB
testcase_29 AC 108 ms
19,308 KB
testcase_30 AC 119 ms
20,628 KB
testcase_31 AC 119 ms
22,212 KB
testcase_32 AC 107 ms
19,044 KB
testcase_33 AC 133 ms
24,060 KB
testcase_34 AC 112 ms
19,572 KB
testcase_35 AC 112 ms
19,572 KB
testcase_36 AC 112 ms
20,628 KB
testcase_37 AC 96 ms
18,780 KB
testcase_38 AC 96 ms
18,780 KB
testcase_39 AC 96 ms
18,780 KB
testcase_40 AC 95 ms
18,780 KB
testcase_41 AC 96 ms
18,780 KB
testcase_42 AC 96 ms
18,780 KB
testcase_43 AC 97 ms
18,780 KB
testcase_44 AC 96 ms
18,780 KB
testcase_45 AC 97 ms
18,780 KB
testcase_46 AC 96 ms
18,780 KB
testcase_47 AC 65 ms
17,196 KB
testcase_48 AC 65 ms
16,932 KB
testcase_49 AC 66 ms
17,460 KB
testcase_50 AC 66 ms
17,460 KB
testcase_51 AC 66 ms
17,160 KB
testcase_52 AC 65 ms
16,668 KB
testcase_53 AC 66 ms
17,196 KB
testcase_54 AC 66 ms
16,932 KB
testcase_55 AC 65 ms
16,668 KB
testcase_56 AC 67 ms
17,460 KB
testcase_57 AC 88 ms
17,500 KB
testcase_58 AC 88 ms
17,500 KB
testcase_59 AC 88 ms
17,500 KB
testcase_60 AC 96 ms
17,460 KB
testcase_61 AC 96 ms
17,460 KB
testcase_62 AC 96 ms
17,460 KB
testcase_63 AC 84 ms
26,840 KB
testcase_64 AC 67 ms
17,684 KB
testcase_65 AC 84 ms
26,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  map<long long, int> mp;
  FOR(i, 2, 200001) mp[1LL * i * (i - 1) / 2] = i;
  int n; cin >> n;
  vector<string> s(n); REP(i, n) cin >> s[i];
  vector<vector<long long> > wei(n);
  wei[0].assign(s[0].length(), 1);
  FOR(i, 1, n) {
    wei[i].assign(s[i].length(), 1);
    REP(j, s[i].length()) {
      if (s[i - 1][j] != s[i][j]) break;
      wei[i][j] = 1LL * mp[wei[i - 1][j]] * (mp[wei[i - 1][j]] + 1) / 2;
    }
  }
  long long ans = 0;
  REP(i, n) ans += accumulate(ALL(wei[i]), 0LL);
  cout << ans << '\n';
  return 0;
}
0