QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#698222 | #8334. Gene | xdz_# | RE | 1ms | 3832kb | C++20 | 1.5kb | 2024-11-01 18:15:23 | 2024-11-01 18:15:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
typedef pair<int,int> PII;
const int mod1 = (1ll << 60),N = 110,M = 60010,mod = 2333;
int h[N][M];
int p[M];
int ha[N];
void solve(){
int n,q,m,k;
cin >>n>>q>>m>>k;
vector<string> s(n + 1);
p[0] = 1;
for(int j = 1;j <= m;j ++){
p[j] = (p[j - 1] * 2333) % mod1;
}
for(int i = 1;i <= n;i ++){
string s1;
cin >>s1;
s1 = " " + s1;
s[i] = s1;
for(int j = 1;j <= m;j ++){
// cout<<s[i]<<' ';
h[i][j] = ((h[i][j - 1] + (s1[j] * p[j]) % mod1)) % mod1;
}
}
auto check = [&](int x,int now,int id){
if((h[id][now + x - 1] - h[id][now - 1] + mod1) % mod1 == (ha[now + x - 1] - ha[now - 1] + mod1) % mod1){
return true;
}
else return false;
};
while(q --){
string t;
cin >>t;
t = " " + t;
for(int i = 1;i <= m;i ++){
ha[i] = (ha[i - 1] + (t[i] * p[i]) % mod1) % mod1;
}
int ans = 0;
for(int i = 1;i <= n;i ++){
int l = 1,r = m;
int f = 0;
for(int j = 0;j <= k;j ++){
int l1 = 0,r1 = r - l + 2;
while(l1 + 1 < r1){
int mid = (l1 + r1) / 2;
if(check(mid,l,i))l1 = mid;
else r1 = mid;
}
if(l1 == r - l + 1){
f = 1;
break;
}
else{
l += l1 + 1;
}
}
if(f)ans ++;
}
cout<<ans<<'\n';
}
}
signed main(){
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
int T;
T = 1;
while(T --){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3688kb
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: 3832kb
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: -100
Runtime Error
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...