Submission #464616

#TimeUsernameProblemLanguageResultExecution timeMemory
464616idk321Lottery (CEOI18_lot)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 10005; int tree[4 * N]; vector<vector<int>> diff; bool vis[N][N]; void add(int from, int to, int a, int b, int node) { if (from <= a && b <= to) { tree[node]++; return; } int mid = (a + b) / 2; if (from <= mid) add(from, to, a, mid, node * 2); if (to > mid) add(from, to, mid + 1, b, node * 2 +1); } int getNum(int i, int a, int b, int node) { if (a == b) return tree[node]; int mid = (a + b) / 2; int res = tree[node]; if (i <= mid) return getNum(i, a, mid, node * 2) + res; return res + getNum(i, mid + 1, b, node * 2 + 1); } int getSumFor(int i, int j) { if (vis[i][j]) return diff[i][j]; vis[i][j] = true; if (i - 1 >= 0 && j - 1 >= 0) { diff[i][j] += getSumFor(i - 1, j - 1); } return diff[i][j]; } int getDist(int i, int j) { int cur = diff[i + l - 1][j + l - 1]; if (i != 0 && j != 0) cur -= diff[i - 1][j - 1]; return cur; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, l; cin >> n >> l; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; int q; cin >> q; vector<int> k(q); for (int i = 0; i < q; i++) cin >> k[i]; diff.resize(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (v[i] != v[j]) diff[i][j] = 1; } for (int i = n - 1; i >= 0; i--) { for (int j = n - 1; j >= 0; j--) { getSumFor(i, j); } } for (int q1 = 0; q1 < q; q1++) { for (int i = 0; i <= n - l; i++) { int cur = 0; for (int j = 0; j <= n - l; j++ ) { if (j == i) continue; if (getDist(i, j) <= k[q1]) cur++; } cout << cur << " "; } cout << "\n"; } } /* 6 2 1 2 1 3 2 1 2 1 2 */

Compilation message (stderr)

lot.cpp: In function 'int getDist(int, int)':
lot.cpp:40:24: error: 'l' was not declared in this scope
   40 |     int cur = diff[i + l - 1][j + l - 1];
      |                        ^