結果

問題 No.430 文字列検索
ユーザー tossy
提出日時 2016-10-02 23:07:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 1,055 bytes
コンパイル時間 1,180 ms
コンパイル使用メモリ 102,512 KB
実行使用メモリ 19,428 KB
最終ジャッジ日時 2024-11-10 00:03:03
合計ジャッジ時間 2,939 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

char c[50010];

int main(){
  vector<vector<string> > vec(10, vector<string>());
  scanf("%s", c);
  string s(c);
  int n = s.length();

  rep(i,n){
    rep(len, 10){
      if(i+len>n) continue;
      vec[len].pb(s.substr(i,len+1));
    }
  }
  rep(i,10) sort(all(vec[i]));

  int m;
  cin>>m;
  int res=0;
  rep(loop, m){
    char ch[15];
    scanf("%s", ch);
    string str(ch);
    int len=str.size();
    res += upper_bound(all(vec[len-1]), str) - lower_bound(all(vec[len-1]), str);
  }

  cout<<res<<endl;

  return 0;
}
0