Submission #482579

#TimeUsernameProblemLanguageResultExecution timeMemory
482579HazemLottery (CEOI18_lot)C++14
0 / 100
3 ms460 KiB
#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)

lot.cpp: In function 'int main()':
lot.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d%d",&n,&l);
      |     ~~~~~^~~~~~~~~~~~~~
lot.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
#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...