結果

問題 No.430 文字列検索
ユーザー miwawawa
提出日時 2024-10-17 16:24:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,842 bytes
コンパイル時間 2,777 ms
コンパイル使用メモリ 263,288 KB
実行使用メモリ 44,468 KB
最終ジャッジ日時 2024-11-10 01:13:43
合計ジャッジ時間 3,915 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#include <cmath>
//#include <ranges>
using ll=long long;
using lu=unsigned long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define chmin(x,b) x=min(x,b)
using namespace std;
#define fi first
#define se second
using P=pair<int,int>;
using PD=pair<double,double>;
using PL=pair<ll,ll>;
using PH=pair<int,char>;
using PS=pair<string,ll>;
int mod1=998244353;
int mod2=1000000007;
const ll INF = 5000000000000000000;
const int big = 2147483647;
ll N=1;
struct st{
ll x,y,z;
st(ll x=0,ll y=0,ll z=0):x(x),y(y),z(z){}
bool operator>(const st &a) const {
if (x != a.x) return x > a.x;
if (y != a.y) return y > a.y;
return z > a.z;
}
};
struct node{
map<char,int>to;
int cnt;
node():cnt(0){}
};
struct trie{
map<char,int>mp;
vector<node>d;
trie():d(1){}
void add(string s){
int v=0;
for(auto c:s){
if(!d[v].to.count(c)){
d[v].to[c]=d.size();
d.push_back(node());
}
v=d[v].to[c];
}
d[v].cnt++;
};
int find(string s){
int v=0;
for(auto c:s){
if(!d[v].to.count(c))return 0;
v=d[v].to[c];
}
return d[v].cnt;
}
};
mt19937_64 rng(1644);
ll mod=(1ll<<61)-1;
int main(){//15:43
ll n=0,q,y=0,i=0,z=0,x=0,d=0,k=0,nk,sum=0;
ll ans=INF,sum2=0,rs=-INF,cs=0,l=0,h=0,r=0;
ll a=0,b=0,c=0,j=0,m=0,K=0;
ll M=0,R,w,L;
string s;
cin>>s;
N=s.size();
cin>>M;
map<ll,ll>mp;
vector<ll>reco(5010);
trie A;
rep(i,0,N){
string tp;
rep(j,0,10){
if(i+j>N-1)break;
tp+=s[i+j];
A.add(tp);
}
}
rep(i,0,M){
string tp;
cin>>tp;
sum+=A.find(tp);
}
cout<<sum<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0