Submission #362886

#TimeUsernameProblemLanguageResultExecution timeMemory
362886NimbostratusLottery (CEOI18_lot)C++11
20 / 100
378 ms1132 KiB
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define ppb pop_back #define ub upper_bound #define lb lower_bound #define bs binary_search #define cl(a,s) memset((a),0,sizeof((a)[0])*(s)) #define all(x) (x).begin() , (x).end() #define fi first #define se second #define int long long using pii = pair<int,int>; using ll = long long; const int maxn = 10005; const int maxq = 105; const int inf = 1e9; const int mod = 1e9+9; vector<int> vec; int n,a[maxn],d[maxn],l,q,k; int ans[maxn]; map<int,int> cnt; void compress() { for(int i=1;i<=n;i++) d[i] = a[i]; sort(d+1,d+n+1); int sz = unique(d+1,d+n+1)-d; for(int i=1;i<=n;i++) a[i] = lb(d+1,d+sz+1,a[i])-d; } int hs() { int ret = 0; int p = 1; for(int x : vec) { ret = (ret + (x * p) % mod)%mod; p = (p * (int)(10007)) % mod; } return ret; } int32_t main () { //freopen("in","r",stdin); freopen("out","w",stdout); ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> l; for(int i=1;i<=n;i++) cin >> a[i]; compress(); cin >> q; for(int i=1;i<=q;i++) cin >> k; vec.resize(l); for(int i=1;i+l-1<=n;i++) { for(int j=i;j<=i+l-1;j++) vec[j-i] = a[j]; cnt[hs()]++; } for(int i=1;i+l-1<=n;i++) { for(int j=i;j<=i+l-1;j++) vec[j-i] = a[j]; cout << cnt[hs()]-1 << " "; } }
#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...