# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
482579 | Hazem | Lottery (CEOI18_lot) | C++14 | 3 ms | 460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e4+1;
const LL MOD = 1e9+7;
int a[N];
LL hashs[N];
map<LL,LL>mp;
set<int>st;
LL mult(LL a,LL b){
return (a*b)%MOD;
}
LL add(LL a,LL b){
return (a+b)%MOD;
}
int main(){
int n,l;
scanf("%d%d",&n,&l);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(int i=1;i<=n-l+1;i++){
LL prime = 23,hash = 1,power = 1;
for(int j=i;j<=i+l-1;j++)
hash = add(hash,mult(a[i],power)),power = mult(power,prime);
mp[hash]++;
hashs[i] = hash;
}
for(int i=1;i<=n-l+1;i++)
printf("%lld ",mp[hashs[i]]-1);
puts("");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |