結果

問題 No.430 文字列検索
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-04-03 23:30:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,319 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 99,244 KB
実行使用メモリ 7,196 KB
最終ジャッジ日時 2023-08-15 17:19:04
合計ジャッジ時間 2,874 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 149 ms
7,196 KB
testcase_02 AC 31 ms
4,380 KB
testcase_03 AC 30 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 148 ms
6,688 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 11 ms
4,376 KB
testcase_11 AC 76 ms
6,000 KB
testcase_12 AC 76 ms
6,108 KB
testcase_13 AC 75 ms
6,244 KB
testcase_14 AC 64 ms
5,360 KB
testcase_15 AC 56 ms
4,644 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 30 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))

#define MOD 1000000007

string s;

int f(int n, vector<string> v){
  int ret = 0;
  map<long long, int> ma;
  rep(i,0,v.sz){
    long long key = 0;
    string s1 = v[i];
    rep(j,0,s1.sz){
      key += (s1[j]-'A')*pow(26,j);
    }
    ma[key]++;
  }
  long long key = 0;
  rep(i,0,n){
    key += (s[i]-'A')*pow(26,i);
  }
  rep(i,n,s.sz){
    ret += ma[key];
    key /= 26;
    key += (s[i]-'A')*pow(26,n-1);
  }
  ret += ma[key];
  return ret;
}

int main(){
  cin>>s;
  int m;
  cin>>m;
  vector<vector<string> > v(11,vector<string>());
  rep(i,0,m){
    string s1;
    cin>>s1;
    v[s1.sz].pb(s1);
  }
  int ans = 0;
  rep(i,1,11){
    if(i<=s.sz){
      ans += f(i,v[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
0