# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261171 | sjimed | Lottery (CEOI18_lot) | C++14 | 569 ms | 4856 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;
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define eb emplace_back
#define em emplace
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
int n, l, q;
int a[10010];
int k[111];
int g[10010];
int ans[10010][111];
int main() {
fast;
cin >> n >> l;
for(int i=1; i<=n; i++) {
cin >> a[i];
}
cin >> q;
vector<int> v;
for(int i=1; i<=q; i++) {
cin >> k[i];
v.eb(k[i]);
}
v.eb(l);
sort(all(v));
v.erase(unique(all(v)), v.end());
for(int i=0, j=0; i<v.size(); i++) {
for( ; j<=v[i]; j++) g[j] = i;
}
for(int i=1; i<=n-l; i++) {
int cnt = 0;
for(int j=1; j<=l; j++) {
if(a[j] != a[j+i]) cnt++;
}
for(int j=1; j+i <= n-l+1; j++) {
ans[g[cnt]][j]++;
ans[g[cnt]][j+i]++;
if(a[j] != a[j+i]) cnt--;
if(a[j+l] != a[j+i+l]) cnt++;
}
}
for(int i=1; i<=q; i++) {
for(int j=1; j<=n-l+1; j++) {
ans[j][i] += ans[j][i-1];
}
}
for(int i=1; i<=q; i++) {
for(int j=1; j<=n-l+1; j++) {
cout << ans[g[k[i]]][j] << " ";
}
cout << "\n";
}
}
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... |