QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#791628 | #8334. Gene | rdcamelot | TL | 0ms | 3700kb | C++20 | 1.6kb | 2024-11-28 19:57:00 | 2024-11-28 19:57:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
using u64=unsigned long long;
#define ll long long
const int inf=1e9;
const ll inff=1e18;
using i128=__int128;
// 分块
constexpr int base=233;
void solve(){
int n,q,m,k;
cin>>n>>q>>m>>k;
int B=sqrt(m/k);
vector<string> s(n);
for(int i=0;i<n;i++){
cin>>s[i];
}
auto hash=[&](const string &s){
vector<u64> res;
for(int l=0,r;l<m;l=r){
r=min(l+B,m);
u64 cur=0;
for(int i=l;i<r;i++){
cur=cur*base+s[i];
}
res.emplace_back(cur);
}
return res;
};
vector<vector<u64>> st(n);
for(int i=0;i<n;i++){
st[i]=hash(s[i]);
}
while(q--){
string t;
cin>>t;
auto cur=hash(t);
int siz=cur.size();
int ans=0;
for(int i=0;i<n;i++){
int cnt=0;
for(int j=0;j<siz;j++){
if(st[i][j]!=cur[j]){
for(int k=j*B;k<min((j+1)*B,m);k++){
if(s[i][k]!=t[k]){
cnt++;
}
}
if(cnt>k){
break;
}
}
}
if(cnt<=k){
ans++;
}
}
cout<<ans<<'\n';
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
input:
6 4 4 1 kaki kika manu nana tepu tero kaka mana teri anan
output:
2 2 1 0
result:
ok 4 number(s): "2 2 1 0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
8 6 7 3 delphis aduncus peronii plumbea clymene hectori griseus electra delphis helpiii perphii clumeee eleelea ddlpcus
output:
1 1 2 2 1 2
result:
ok 6 numbers
Test #3:
score: -100
Time Limit Exceeded
input:
300 300 9 10 dmzampmxe bteaudaxb fjfwhhsfq btnfzqtyp ijjrkbyht hkizlvgdc ukwsnhiff hacsdrwyl fbjabnhst ktsxbgbtg jopdbsdsr yxdxxjltd daechsouq klrglgwbn llzhqzlor ckdedutfn lkjxcryoe zvusjevtz cevrcdltg tdmmvvpkj davfsweem spcfhcitm aohsfqrqh lblehevpj soaqryimp tbxlulxmn tnlzbkhda ukfhjykuk eghpuua...