Submission #917964

#TimeUsernameProblemLanguageResultExecution timeMemory
917964PM1Lottery (CEOI18_lot)C++17
20 / 100
203 ms928 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxn=1e4+5,M=1e9+7; ll ans[mxn],n,q,a[mxn],l,base=727; map<int,int>mp; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>l; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n-l+1;i++){ ll hs=0; for(int j=i;j<i+l;j++){ hs=((hs*base)%M+a[j])%M; } ans[i]=hs; mp[hs]++; } cin>>q; for(int i=1;i<=q;i++){ int x; cin>>x; for(int j=1;j<=n-l+1;j++){ cout<<mp[ans[j]]-1<<" "; } cout<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...