# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068714 | PotatoTheWarriorFRTT | Lottery (CEOI18_lot) | C++14 | 104 ms | 1380 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>
using namespace std;
typedef long long ll;
ll p1 = 27644437;
ll p2 = 1000000007;
// ll power(ll x, ll y) {
// y = y%MOD;
// x = x%MOD;
// ll res = 1;
// while(y != 0) {
// if(y%2) {
// res = (res*x)%MOD;
// }
// x = (x*x)%MOD;
// y/=2;
// }
// return res;
// }
void solve() {
int n, l; cin >> n >> l;
int a[n+1];
set<ll> s;
map<ll, vector<int>> mape;
for(int i=0;i<n;i++) {
int x; cin >> x;
s.insert(x);
mape[x].push_back(i);
}
int k = 0;
for(ll l: s) {
for(int i=0;i<mape[l].size();i++) {
a[mape[l][i]] = k;
}
k++;
}
ll powers[l+1];
powers[0] = 1;
for(int i=0;i<l-1;i++) {
powers[i+1] = (powers[i] * p1)%p2;
}
unordered_map<ll, ll> m;
ll hashes[n+1];
for(int i=0;i<n-l+1;i++) {
ll hash = 0;
for(int j=0;j<l;j++) {
hash = (hash + (a[i+j] * powers[j]))%p2;
}
hashes[i] = hash;
m[hash]++;
}
int q; cin >> q;
int ki; cin >> ki; // q=0;k=1;
for(int i=0;i<n-l+1;i++) {
cout << m[hashes[i]]-1 << " ";
}
cout << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// int t; cin >> t;
// while(t--)
solve();
char dksfjn;
cin >> dksfjn;
}
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... |