# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
482575 | Hazem | Lottery (CEOI18_lot) | C++14 | 2 ms | 332 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],hashs[N];
map<int,int>mp;
set<int>st;
int mult(LL a,LL b){
return (a*b)%MOD;
}
int 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++){
int prime = 23,hash = 1,power = 23;
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("%d ",mp[hashs[i]]);
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... |