QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686988 | #8334. Gene | ospoasa | WA | 8ms | 6112kb | C++14 | 2.0kb | 2024-10-29 16:38:01 | 2024-10-29 16:38:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using UL = unsigned long long;
using LL = long long;
const LL mod = 1e9 + 7;
const int N = 310;
const int M = 6e4 + 10;
string S[N], Q[N];
// UL U1[N][M], U2[N][M], m293[M];
LL L1[N][M], L2[N][M], m131[M];
int n, q, m, k;
void hs()
{
// m293[0] = 1;
m131[0] = 1;
for(int i = 1; i <= m; i++) m131[i] = m131[i - 1] * 293 % mod;
// for(int i = 1; i <= m; i++) m293[i] = m293[i - 1] * (UL)293;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
// U1[i][j] = U1[i][j - 1] * (UL)293 + (UL)S[i][j];
// U2[i][j] = U2[i][j - 1] * (UL)293 + (UL)Q[i][j];
L1[i][j] = (L1[i][j - 1] * 131 + S[i][j]) % mod;
L2[i][j] = (L2[i][j - 1] * 131 + Q[i][j]) % mod;
}
}
}
bool same(int i, int j, int l, int r) {
if(r > m) return true;
// if(U2[i][r] - U2[i][l - 1] * m293[r - l] != U1[j][r] - U1[j][l - 1] * m293[r - l])
// return false;
if((L2[i][r] - L2[i][l - 1] * m131[r - l] % mod + mod) % mod != (L1[j][r] - L1[j][l - 1] * m131[r - l] % mod + mod) % mod)
return false;
return true;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q >> m >> k;
for(int i = 1; i <= n; i++) cin >> S[i];
for(int i = 1; i <= q; i++) cin >> Q[i];
hs();
for(int i = 1; i <= q; i++) {
int res = 0;
for(int j = 1; j <= n; j++) {
int cnt = 0, p = 1;
while(p < m)
{
while(Q[i][p - 1] != S[j][p - 1] && cnt <= k && p <= m) p++, cnt++;
if(cnt > k || p > m) break;
int r = 1;
if(same(i, j, p, p + r))
while(1) {// q, n, [l, r]
if(same(i, j, p, p + (r << 1))) r <<= 1;
else break;
if(p + r >= m) break;
};
p += r;
}
if(cnt <= k) res++;
}
cout << res << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 3740kb
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: 3ms
memory: 6052kb
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: 0ms
memory: 6112kb
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: 4ms
memory: 6060kb
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: 3ms
memory: 6052kb
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: 8ms
memory: 6076kb
input:
300 300 15 10 bbjbbbjbjbbjjbb bbjbbbbjbjjjbbb jbjjjjbjbbjbjbb bbjjjbjbbjbbjbb bjbjjjbbbbbbbbb bjbjbjjjbjjjjjj bbbjjbbjjjbjjjb bjbbjbjbjbjjjjj bbbbbjbjjjjbjbj bbbjbbbbjbjjjjb jjjbbbbbbbjjbbj jbbjjjbbbbjbjbb bjjbbjbjbjbjjjj bbjbbjbjbjjbbbb jbjjjjbbbbjjjbj bbbbjbbbbbjjbjj jbjbjjbbjjbjjjb jjbjbjjbbbjjjj...
output:
283 286 292 285 286 282 284 282 287 281 289 293 281 282 282 287 281 283 283 286 286 284 290 280 289 287 287 280 287 285 290 282 288 286 278 291 289 283 285 290 291 279 282 281 289 290 277 276 283 289 284 284 283 282 288 287 278 284 285 282 285 285 294 281 289 283 288 290 289 279 280 287 287 286 281 ...
result:
wrong answer 1st numbers differ - expected: '279', found: '283'