QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714391 | #8334. Gene | xinlengweishang | WA | 16ms | 288532kb | C++20 | 3.2kb | 2024-11-05 23:00:03 | 2024-11-05 23:00:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e9 + 5;
const long long M1 = 998244353ll, M2 = 19260817ll, d1 = 233ll, d2 = 2333ll;
ll f1[309][60009], f2[309][60009], t1[60009], t2[60009], di1[60009], di2[60009];
string st[309], s;
ll flag, chunk[25], ck, n, m, q;
void gan(int l, int r, int k, int c)
{
// cout<<k<<" "<<l<<" "<<r<<" "<<c<<" "<<chunk[c]<<" \n";
if (chunk[c] > ck+2)
{
flag = 20;
return;
}
if (r - l + 1 <= 1)
{
// cout<<"&"<<l<<"---"<<r<<endl;
for (int i = l; i <= r; i++)
if (st[k][i-1] != s[i-1]){
flag++;
// cout<<"&"<<i<<endl;
}
return;
}
if (flag > ck)
return;
ll s1 = f1[k][r] - f1[k][l - 1];
ll s2 = f2[k][r] - f2[k][l - 1];
ll s3 = t1[r] - t1[l - 1];
ll s4 = t2[r] - t2[l - 1];
if (s1 == s3 && s2 == s4)
return;
int mid = (l + r) >> 1;
s1 = f1[k][mid] - f1[k][l - 1];
s2 = f2[k][mid] - f2[k][l - 1];
s3 = t1[mid] - t1[l - 1];
s4 = t2[mid] - t2[l - 1];
// cout<<"#"<<l<<"--"<<mid<<":"<<s1<<" "<<s3<<" "<<s2<<" "<<s4<<endl;
if (s1 != s3 || s2 != s4)
{
chunk[c + 1]++;
gan(l, mid, k, c + 1);
}
if (flag > ck)
return;
s1 = f1[k][r] - f1[k][mid];
s2 = f2[k][r] - f2[k][mid];
s3 = t1[r] - t1[mid];
s4 = t2[r] - t2[mid];
// cout<<"#"<<mid+1<<"--"<<r<<":"<<s1<<" "<<s3<<" "<<s2<<" "<<s4<<endl;
if (s1 != s3 || s2 != s4)
{
chunk[c + 1]++;
gan(mid + 1, r, k, c + 1);
}
}
int main()
{
scanf("%lld%lld%lld%lld", &n, &q, &m, &ck);
char ch = getchar();
di1[0] = 1;
di2[0] = 1;
for (int i = 1; i <= m; i++)
{
di1[i] = di1[i - 1] * d1;
di1[i] %= M1;
di2[i] = di2[i - 1] * d2;
di2[i] %= M2;
}
for (int i = 1; i <= n; i++)
{
getline(cin, st[i]);
f1[i][1] = st[i][0];
f2[i][1] = st[i][0];
f1[i][1] %= M1;
f2[i][1] %= M2;
for (int j = 2; j <= m; j++)
{
f1[i][j] = f1[i][j - 1] + st[i][j-1] * di1[j-1];
f1[i][j] %= M1;
f2[i][j] = f2[i][j - 1] + st[i][j-1] * di2[j-1];
f2[i][j] %= M2;
// cout<<f1[i][j]<<" ";
}
// cout<<endl;
}
while (q--)
{
// cout<<"\n!"<<q<<endl;
getline(cin, s);
int ans = 0;
t1[1] = s[0];
t2[1] = s[0];
t1[1] %= M1;
t2[1] %= M2;
for (int j = 2; j <= m; j++)
{
t1[j] = t1[j - 1] + s[j-1] * di1[j-1];
t1[j] %= M1;
t2[j] = t2[j - 1] + s[j-1] * di2[j-1];
t2[j] %= M2;
}
for (int i = 1; i <= n; i++)
{
flag = 0;
memset(chunk, 0, sizeof(chunk));
gan(1, m, i, 1);
if (flag <= ck)
ans++;
}
printf("%lld\n", ans);
}
return 0;
}
/*
6 4 4 1
kaki
kika
manu
nana
tepu
tero
kaka
mana
teri
anan
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 14200kb
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: 2ms
memory: 11980kb
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: 288448kb
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: 11ms
memory: 286588kb
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: 8ms
memory: 288512kb
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: 12ms
memory: 288532kb
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: 16ms
memory: 288476kb
input:
300 300 15 10 bbjbbbjbjbbjjbb bbjbbbbjbjjjbbb jbjjjjbjbbjbjbb bbjjjbjbbjbbjbb bjbjjjbbbbbbbbb bjbjbjjjbjjjjjj bbbjjbbjjjbjjjb bjbbjbjbjbjjjjj bbbbbjbjjjjbjbj bbbjbbbbjbjjjjb jjjbbbbbbbjjbbj jbbjjjbbbbjbjbb bjjbbjbjbjbjjjj bbjbbjbjbjjbbbb jbjjjjbbbbjjjbj bbbbjbbbbbjjbjj jbjbjjbbjjbjjjb jjbjbjjbbbjjjj...
output:
279 285 287 279 280 276 277 278 281 275 285 287 276 277 276 278 273 281 276 279 280 278 286 275 287 284 285 276 279 281 276 272 284 282 269 285 283 280 281 284 289 274 277 276 283 287 274 271 279 287 270 281 278 276 274 280 277 270 280 277 280 280 289 277 278 276 284 286 285 274 272 286 284 284 276 ...
result:
wrong answer 3rd numbers differ - expected: '291', found: '287'