# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
949515 |
2024-03-19T10:06:11 Z |
glebustim |
Lottery (CEOI18_lot) |
C++17 |
|
372 ms |
1132 KB |
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
int main() {
fast;
int n, l;
cin >> n >> l;
vi a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
int q;
cin >> q;
vector<pii> qs(q);
for (int i = 0; i < q; ++i) {
cin >> qs[i].first;
qs[i].second = i;
}
sort(all(qs));
vi g(n + 1);
for (int i = 0; i <= n; ++i)
g[i] = lower_bound(all(qs), make_pair(i, 0)) - qs.begin();
vector<vi> d(n, vi(q, 0));
for (int k = 1; k < n; ++k) {
vi b(n + 1, 0);
for (int i = 0; i + k < n; ++i) {
int j = i + k;
if (a[i] == a[j])
continue;
++b[max(i - l + 1, 0)];
--b[i - max(j + l - n, 0) + 1];
}
int x = 0;
for (int i = 0; i + k < n; ++i) {
int j = i + k;
x += b[i];
++d[i][g[x]];
++d[j][g[x]];
}
}
vector<vi> ans(q, vi(n - l + 1, 0));
for (int i = 0; i <= n - l; ++i) {
int x = 0;
for (int j = 0; j < q; ++j) {
x += d[i][j];
ans[qs[j].second][i] = x;
}
}
for (int i = 0; i < q; ++i) {
for (int j = 0; j <= n - l; ++j)
cout << ans[i][j] - 1 << ' ';
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
372 ms |
1132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
372 ms |
1132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |