結果

問題 No.430 文字列検索
ユーザー kyuridenamidakyuridenamida
提出日時 2016-10-28 18:56:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 74,592 KB
実行使用メモリ 32,256 KB
最終ジャッジ日時 2024-05-03 07:18:58
合計ジャッジ時間 1,790 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 160 ms
32,256 KB
testcase_02 AC 7 ms
5,376 KB
testcase_03 AC 7 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 158 ms
31,872 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 10 ms
6,272 KB
testcase_11 AC 59 ms
8,320 KB
testcase_12 AC 58 ms
8,320 KB
testcase_13 AC 58 ms
8,576 KB
testcase_14 AC 44 ms
6,528 KB
testcase_15 AC 35 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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