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>
using namespace std;
int main()
{
int l, n;
cin >> n >> l;
vector<int> a(n);
vector<__int128_t> hashe(n-l+1);
for(auto &i:a) cin >> i;
__int128_t almoptrime = 1e9+3;
almoptrime=almoptrime*almoptrime*almoptrime*almoptrime+7;
for(int i = 0; i < n-l+1; i++)
{
__int128_t has = 0;
for(int llll = 0; llll < l; llll++)
{
has+=a[i+llll];
has*=1e9+7;
has%=almoptrime;
}
hashe[i]=has;
}
int q;
cin >> q;
while(q--)
{
int k;
cin >> k;
for(int i = 0; i < n-l+1; i++)
{
int ans = 0;
for(int j = 0; j < n-l+1; j++)
{
if (i==j) continue;
if(hashe[i]==hashe[j]) ans++;
}
cout << ans << ' ';
}
cout << '\n';
}
return 0;
}
# | 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... |