QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#766397 | #8334. Gene | qilou | WA | 0ms | 3860kb | C++23 | 3.7kb | 2024-11-20 17:11:50 | 2024-11-20 17:11:50 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
#define ok cout<<"OK\n";
#define pii pair<int,int>
#define endl "\n"
typedef long long LL;
using namespace std;
// const int N=5e5+10;
// int mod=1e9+7;
// int p[N];
// int a[N];
// struct node {
// int l,r,mn,mx,res;
// }tr[N*4];
// int find(int x) {
// if(x==p[x])return x;
// return p[x]=find(p[x]);
// }
// void js(int p,int l,int r) {
// tr[p]={l,r};
// if(l==r) {
// tr[p].mn=tr[p].res=tr[p].mx=a[l];
// return;
// }
// int mid=(l+r)/2;
// js(p,l,mid);
// js(p,mid+1,r);
// tr[p].mn=min(tr[p*2].mn,tr[p*2+1].mn);
// tr[p].mx=max(tr[p*2].mx,tr[p*2+1].mx);
// }
// int findmn(int p,int l,int r,int pl,int pr) {
// if(pl<=r&&r<=pr) {
// return tr[p].mn;
// }
// int mid=(l+r)/2;
// if(pr<=mid)return findmn(p,l,mid,pl,pr);
// else if(pl>mid)return findmn(p,mid+1,r,pl,pr);
// else return min(findmn(p,l,mid,pl,pr),findmn(p,mid+1,r,pl,pr) );
// }
//
// int findmx(int p,int l,int r,int pl,int pr) {
// if(pl<=r&&r<=pr) {
// return tr[p].mx;
// }
// int mid=(l+r)/2;
// if(pr<=mid)return findmx(p,l,mid,pl,pr);
// else if(pl>mid)return findmx(p,mid+1,r,pl,pr);
// else return max(findmx(p,l,mid,pl,pr),findmx(p,mid+1,r,pl,pr) );
// }
//5 7 3 6
const int N=3e5+10;
int dfn[N],low[N];
using ull = unsigned long long;
const ull P = 133331;
struct Hash {
const int n;
std::vector<ull> p, h1, h2;
std::string s;
Hash(std::string s_) : s(s_), n(s_.size() - 1), h1(n + 2), h2(n + 2), p(n + 2) { // idx by 1
p[0] = 1; h1[0] = 0, h2[0] = 0;
for(int i = 1 ; i <= n ; i ++) p[i] = p[i - 1] * P;
for(int i = 1 ; i <= n ; i ++) h1[i] = h1[i - 1] * P + s_[i];
for(int i = n ; i >= 1 ; i --) h2[i] = h2[i + 1] * P + s_[i];
}
ull get(int l, int r) { // s[l] s[l + 1] ... s[r]
return h1[r] - h1[l - 1] * p[r - l + 1];
}
ull get_unnomal(int l, int r, int L, int R) { // s[l] s[l + 1] ... s[r] s[L] s[L + 1]...s[R]
return get(l, r) * p[R - L + 1] + get(L, R);
}
ull get_rev(int l, int r) { // s[r] s[r - 1] ... s[l]
return h2[l] - h2[r + 1] * p[r - l + 1];
}
ull modify(std::string &s, int idx, char c) { // 修改 idx 位为 x的hash值
return h1[n] + p[n - idx] * (c - s[idx]);
}
};
void solve() {
int n,m,q,k;
cin>>n>>q>>m>>k;
vector<Hash> ls;
for(int i=1;i<=n;i++) {
string s;
cin>>s;
s=" "+s;
Hash c(s);
ls.push_back(c);
//cout<<ls[i-1].get(1,2)<<endl;;
}
while (q--)
{
string s;
cin>>s;
//cin>>s;
s=" "+s;
int ans=0;
Hash c(s);
for(auto o:ls){
int cnt=k;
int nowl=1,nowr=m+1;
for(int i=1;nowl<=m&&i<=k+1;i++){
int l=nowl,r=nowr;
while(l<r){
int mid=(l+r)/2;
int pv=c.get(l,mid),mv=ls[i].get(l,mid);
if(pv==mv){
l=mid+1;
}else r=mid;
}
if(l<=m)cnt--;
nowl=l+1;
}
//cout<<cnt<<" "<<s<<endl;
if(cnt<0)ans++;
}
cout<<n-ans<<endl;
}
}
signed main(){
#ifdef ACM
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
#endif
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T=1;
//init();
//cin>>T;
while(T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3860kb
input:
6 4 4 1 kaki kika manu nana tepu tero kaka mana teri anan
output:
0 0 0 0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'