結果
| 問題 | No.430 文字列検索 | 
| コンテスト | |
| ユーザー |  alpha_virginis | 
| 提出日時 | 2016-12-14 16:07:02 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 312 ms / 2,000 ms | 
| コード長 | 1,212 bytes | 
| コンパイル時間 | 1,886 ms | 
| コンパイル使用メモリ | 175,604 KB | 
| 実行使用メモリ | 26,752 KB | 
| 最終ジャッジ日時 | 2024-11-10 00:13:01 | 
| 合計ジャッジ時間 | 3,330 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
char ss[51234];
long res;
int m;
std::map<uint64_t, int> counter;
uint64_t keys[16][256];
void setup() {
  int n = strlen(ss);
  for(int i = 0; i < n; ++i) {
    uint64_t key = 0ULL;
    for(int j = 0; j < 10; ++j) {
      key += keys[j][(int)ss[i+j]];
      counter[key] = 1 + counter[key];
    }
  }
}
void init() {
  std::random_device r1;
  std::mt19937_64 r2(r1());
  for(int i = 0; i < 16; ++i) {
    for(int j = 0; j < 256; ++j) {
      keys[i][j] = r2();
    }
  }
}
int main() {
  init();
  scanf("%s", ss);
  setup();
  scanf("%d", &m);
  long res = 0;
  for(int i = 0; i < m; ++i) {
    char xs[32];
    scanf("%s", xs);
    int n = strlen(xs);
    uint64_t key = 0ULL;
    for(int j = 0; j < n; ++j) {
      key += keys[j][(int)xs[j]];
    }
    dumpi(counter[key]);
    res += counter[key];
  }
  printf("%ld\n", res);
  return 0;
}
            
            
            
        