結果

問題 No.430 文字列検索
ユーザー kyuridenamida
提出日時 2016-10-28 18:56:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 74,332 KB
実行使用メモリ 32,256 KB
最終ジャッジ日時 2024-11-10 00:12:13
合計ジャッジ時間 1,973 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
using namespace std;
typedef unsigned __int128 Hash;


map<Hash,int> mm[11];

int main(){
	string S;
	int M;
	cin >> S;
	cin >> M;
	for(int i = 0 ; i < S.size() ; i++){
		Hash w = 0;
		for(int j = 0 ; j < 10 and i + j < S.size() ; j++){
			w = w * 128 + S[i+j];
			mm[j+1][w]++;
		}
	}
	long long ans = 0;
	while(M--){
		cin >> S;
		Hash w = 0;
		for(int j = 0 ; j < S.size() ; j++){
			w = w * 128 + S[j];
		}
		ans += mm[S.size()][w];
	}
	cout << ans << endl;
}
0