QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793383#8334. GeneMaxduan#WA 28ms7348kbC++201.9kb2024-11-29 19:16:262024-11-29 19:16:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-29 19:16:26]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:7348kb
  • [2024-11-29 19:16:26]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
#define endl '\n'
using namespace std;

const int mod = 998244353;
const int N = 305;
const int M = 6e4 + 5;
const int base = 237;
int n,m,q,k;
int h[N][M];
int d[M];

void init(){
    d[0]=1;
    for(int i=1;i<=6e4;i++){
        d[i]=d[i-1]*base%mod;
    }
    return;
}
int f(int no,int l,int r){
    int res=0;
    res=(h[no][r]-(h[no][l-1]*d[r-l+1]%mod)+mod)%mod;
    return res;
}


void cal(){
    string s;
    cin>>s;
    s="#"+s;
    for(int i=1;i<=m;i++){
        h[n+1][i]=(h[n+1][i-1]*base+s[i])%mod;
        
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        queue<pair<int,int>> que;
        que.push({1,m});
        ans++;
        while(!que.empty()){
            int cnt=que.size();
            if(cnt>k){
                ans--;
                break;
            }
            while(cnt--){
                int l=que.front().first;
                int r=que.front().second;
                que.pop();
                int mid=(l+r)/2;
                if(f(i,l,r)!=f(n+1,l,r)&&l!=r){
                    if(f(i,l,mid)!=f(n+1,l,mid)){
                        que.push({l,mid});
                    }
                    if(f(i,mid+1,r)!=f(n+1,mid+1,r)){
                        que.push({mid+1,r});
                    }
                }
            }
        }        
    }
    // cout<<f(1,1,4)<<endl;
    // cout<<f(n+1,1,4)<<endl;
    cout<<ans<<endl;
    return;
}

void solve(){
    init();
    cin>>n>>q>>m>>k;
    for(int t=1;t<=n;t++){
        string s;
        cin>>s;
        s="#"+s;
        for(int i=1;i<=m;i++){
            h[t][i]=(h[t][i-1]*base+s[i])%mod;
        }
    }
    while(q--){
        cal();
    }
    return;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TT=1;//cin>>TT;
    while(TT--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4000kb

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: 1ms
memory: 4124kb

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: 23ms
memory: 5248kb

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: 26ms
memory: 7220kb

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: 28ms
memory: 7348kb

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:

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:

wrong answer 1st numbers differ - expected: '96', found: '300'