QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#716799 | #8334. Gene | xinlengweishang | WA | 12ms | 177288kb | C++20 | 2.1kb | 2024-11-06 16:04:48 | 2024-11-06 16:04:51 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define Mod 998244353
#define sushu 23
using namespace std;
char s[400][70000],t[70000];
ll f[400][70000];
ll g[70000];
ll qp[70000];
ll n,q,m,k;
ll flag;
int check(ll x,ll l ,ll r){
if(f[x][r]-f[x][l-1]*qp[l-1]==g[r]-g[l-1]*qp[l-1]) return 1;
else return 0;
}
void sslove(ll x,ll l,ll r){
// printf(" %lld %lld %lld\n",x,l,r);
flag--;
if(flag>k) return ;
if(r-l+1<=2){
for(int i=l;i<=r;i++){
if(s[x][i]!=t[i]) flag++;
}
// printf(" check : %lld %lld %lld flag=%lld\n",x,l,r,flag);
return ;
}
ll mid=(l+r)>>1;
if(!check(x,l,mid)){
flag++;
sslove(x,l,mid);
}
if(flag>k) return ;
if(!check(x,mid+1,r)){
// for(int i=mid+1;i<=r;i++){
// printf(" %d s: %c t: %c\n",i,s[x][i],t[i]);
// }
// printf(" s: %lld t: %lld\n",f[x][r]-f[x][mid],g[r]-g[mid]);
flag++;
sslove(x,mid+1,r);
}
return ;
}
void slove(){
scanf("%lld%lld%lld%lld",&n,&q,&m,&k);
for(int i=1;i<=n;i++){
scanf("%s",s[i]+1);
f[i][0]=0;
for(int q=1;q<=m;q++){
f[i][q]=(f[i][q-1]*sushu+s[i][q]-'a'+1)%Mod;
}
}
// for(int i=1;i<=n;i++){
// printf("%s\n",s[i]+1);
// for(int q=1;q<=m;q++){
// printf("%d %d %lld\n",i,q,f[i][q]);
// }
// }
for(int i=1;i<=q;i++){
scanf("%s",t+1);
g[0]=0;
int ans=0;
for(int q=1;q<=m;q++){
g[q]=(g[q-1]*sushu+t[q]-'a'+1)%Mod;
// printf(" %d g[q]=%lld g[q-1]=%lld %c \n",i,g[q],g[q-1],t[q]);
}
// printf("%s\n",t+1);
// for(int q=1;q<=m;q++){
// printf(" %d %lld\n",q,g[q]);
// }
for(int q=1;q<=n;q++){
if(check(q,1,m)){
ans++;
}
else{
flag=1;
sslove(q,1,m);
// printf("%d %d %d\n",i,q,flag);
if(flag<=k){
ans++;
}
}
}
printf("%d\n",ans);
}
}
int main(){
qp[0]=1;
for(int i=1;i<=600010;i++){
qp[i]=(qp[i-1]*sushu)%Mod;
}
int T=1;
while(T--) slove();
return 0;
}
/*
6 4 4 1
kaki
kika
manu
nana
tepu
tero
kaka
mana
teri
anan
*/
/*
8 2 7 3
delphis
aduncus
peronii
plumbea
clymene
hectori
griseus
electra
eleelea
ddlpcus
*/
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 11900kb
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: 4ms
memory: 12476kb
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: 0
Accepted
time: 8ms
memory: 177288kb
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...
output:
300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 ...
result:
ok 300 numbers
Test #4:
score: 0
Accepted
time: 7ms
memory: 152528kb
input:
300 300 10 10 qoecfhznxd hkoaiunzim lhtzdmbrjs vqesfzpiuv amsgqjxmbq vptwyshswk sofrfmsrpf eplnexhmoh gcjtqavjga azytravylz akpuemdfpq oxkacujrhg bsgieguzuo bojvtfkbdf pmqmrbceej zgpfkqfeyx qkdbfrxqcj effpkigdcw kqyqmgjdzr czlbscrnaq rymhkenugz fuybclhlhj rtmclsdvwy rhfbfqfrfs bpemthjxfi jtcvqyltgj ...
output:
300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 ...
result:
ok 300 numbers
Test #5:
score: -100
Wrong Answer
time: 12ms
memory: 163528kb
input:
300 300 11 10 lonodhfyrbj njzuczzviuj usovdmjfjco bljtnmsjhut kkkeybjagck tbuivwfvjit qhjzqocsvod ayobjbagcgv dudupzsvqpe tcapottzyte wdevxapvocr hsvdfaahndr jjplhydycgn srrtpmqmygw gjjbcchwcur uivvuqldryj amlidxfsobz ofpnwqrzhly eolqcyidojx jpiybuplwcf jmxxtjnwsru ivkbixrgnph txjjppqkxgu vmmbwxmvjd...
output:
96 109 114 109 108 95 108 110 113 107 104 94 111 109 95 107 92 101 111 101 105 116 117 109 106 115 116 96 109 95 114 87 94 116 95 97 105 107 91 103 103 92 115 103 120 102 115 103 101 105 108 95 118 106 91 98 99 115 101 106 120 91 118 91 111 99 104 101 104 96 98 116 111 110 107 118 94 96 103 107 108 ...
result:
wrong answer 4th numbers differ - expected: '108', found: '109'