QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706700 | #8334. Gene | XiCen | WA | 33ms | 11736kb | C++20 | 1.8kb | 2024-11-03 13:01:59 | 2024-11-03 13:02:00 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
const int base = 199,mod1 = 1e11 + 1111,mod2 = 1e15 + 1551,N = 1e6 + 6;
int powb[N];
int Hash(std::string &s,std::vector<int> &hs,int m)
{
hs[m] = s[m];
for(int i = m - 1;i >= 0;--i)
hs[i] = (hs[i + 1] * base + s[i]) % mod1;
return hs[0];
}
int getnum(std::vector<int> &H,int L,int R)
{
return (H[L] - H[R + 1] * powb[R - L + 1] % mod1 + mod1) % mod1;
}
int check(std::vector<int>& H,std::vector<int> &h,int k,int i)
{
//std::cout<<k<<" "<<i<<"\n";
if(k < 0)return 0;
int L = i,R = H.size();
while(R - L > 1)
{
int mid = (L + R) >> 1;
//std::cout<<L<<" "<<mid<<" "<<R<<"\n";
if(mid == H.size() - 1){
if(H[i + 1] == h[i + 1])L = mid;else R = mid;
}
if(mid != H.size() - 1){
if(getnum(H,i + 1,mid) == getnum(h,i + 1,mid))L = mid;else R = mid;
}
}
if(R != H.size())return check(H,h,k-1,R);
return 1;
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);std::cout.tie(0);
powb[0] = 1;
for(int i = 1;i<N;++i)powb[i] = powb[i - 1] * base % mod1;
int n,q,m,k;
std::cin>>n>>q>>m>>k;
std::vector<int> h(m+1,0);
std::vector<std::vector<int>> H(n+1,std::vector<int>(m+1,0));
for(int i = 1;i<=n;++i)
{
std::string s;
std::cin>>s;
s = "!" + s;
Hash(s,H[i],m);
}
for(int qi = 1;qi<=q;++qi)
{
std::string s;
std::cin>>s;
s = "!" + s;
for(int i = 0;i<=m;++i)h[i] = 0;
Hash(s,h,m);
int ans = 0;
for(int i = 1;i<=n;++i)ans += check(H[i],h,k,0);
std::cout<<ans<<"\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 6ms
memory: 11492kb
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: 6ms
memory: 11288kb
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: 25ms
memory: 11736kb
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: 22ms
memory: 11500kb
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: 0
Accepted
time: 28ms
memory: 11496kb
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 108 108 95 108 109 113 106 104 94 111 108 95 107 91 99 111 101 105 116 117 109 106 115 116 96 108 95 114 87 94 116 95 97 104 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 1...
result:
ok 300 numbers
Test #6:
score: 0
Accepted
time: 26ms
memory: 11436kb
input:
300 300 11 10 bacdccbdbba ccabcddcbdc ddbcccadbab cbdcabcddbd ccddbaacaba addabdbbcba ccbcbadadac cbadacadcbb abddacbcada ccccbdccdda dadcbdbddda acbdccdbcdc bbbbdbcdcbc cdcbabdacda acbcdaaadbc dccbdcddcca abbacddccba cccabdcacda ddcadbabbca babaaabbabd dabdaacaddc cabcacbdcda cdbbbdcddcd cdbdccadda...
output:
287 292 286 279 286 285 289 289 294 284 287 291 287 286 283 275 284 291 289 289 286 291 287 282 290 282 278 288 285 285 285 289 287 283 287 290 287 288 292 288 286 290 290 288 289 285 289 276 286 289 283 279 288 288 288 289 289 286 281 288 291 290 287 289 285 280 289 287 286 295 284 285 286 279 284 ...
result:
ok 300 numbers
Test #7:
score: -100
Wrong Answer
time: 33ms
memory: 11504kb
input:
300 300 15 10 bbjbbbjbjbbjjbb bbjbbbbjbjjjbbb jbjjjjbjbbjbjbb bbjjjbjbbjbbjbb bjbjjjbbbbbbbbb bjbjbjjjbjjjjjj bbbjjbbjjjbjjjb bjbbjbjbjbjjjjj bbbbbjbjjjjbjbj bbbjbbbbjbjjjjb jjjbbbbbbbjjbbj jbbjjjbbbbjbjbb bjjbbjbjbjbjjjj bbjbbjbjbjjbbbb jbjjjjbbbbjjjbj bbbbjbbbbbjjbjj jbjbjjbbjjbjjjb jjbjbjjbbbjjjj...
output:
277 285 291 281 283 276 280 280 281 280 284 290 279 281 279 286 276 280 279 284 282 279 288 276 288 285 284 278 283 281 284 278 285 283 273 284 286 282 281 287 289 275 279 279 285 285 274 272 279 288 280 283 279 280 285 282 276 282 284 279 284 281 291 279 282 279 286 287 287 274 274 286 286 283 278 ...
result:
wrong answer 1st numbers differ - expected: '279', found: '277'