QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714404 | #8334. Gene | xinlengweishang | WA | 73ms | 146512kb | C++20 | 3.4kb | 2024-11-05 23:03:50 | 2024-11-05 23:03:56 |
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)
{
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++;
if(m==15){
printf("q=%d i=%d ",q,i);
for(int q=1;q<=15;q++) printf("%d ",chunk[q]);
printf(" | ");
}
}
if(m!=15)
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: 2ms
memory: 12036kb
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: 0ms
memory: 16128kb
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: 7ms
memory: 138220kb
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: 146396kb
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: 140196kb
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: 15ms
memory: 146512kb
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: 73ms
memory: 144484kb
input:
300 300 15 10 bbjbbbjbjbbjjbb bbjbbbbjbjjjbbb jbjjjjbjbbjbjbb bbjjjbjbbjbbjbb bjbjjjbbbbbbbbb bjbjbjjjbjjjjjj bbbjjbbjjjbjjjb bjbbjbjbjbjjjjj bbbbbjbjjjjbjbj bbbjbbbbjbjjjjb jjjbbbbbbbjjbbj jbbjjjbbbbjbjbb bjjbbjbjbjbjjjj bbjbbjbjbjjbbbb jbjjjjbbbbjjjbj bbbbjbbbbbjjbjj jbjbjjbbjjbjjjb jjbjbjjbbbjjjj...
output:
q=299 i=1 0 2 4 6 9 0 0 0 0 0 0 0 0 0 0 | q=299 i=2 0 2 4 6 8 0 0 0 0 0 0 0 0 0 0 | q=299 i=3 0 2 3 5 6 0 0 0 0 0 0 0 0 0 0 | q=299 i=4 0 2 4 8 10 0 0 0 0 0 0 0 0 0 0 | q=299 i=5 0 2 4 6 7 0 0 0 0 0 0 0 0 0 0 | q=299 i=6 0 2 4 6 11 0 0 0 0 0 0 0 0 0 0 | q=299 i=7 0 2 4 7 11 0 0 0 0 0 0 0 0 0 0...
result:
wrong output format Expected integer, but "q=299" found