Submission #132855

#TimeUsernameProblemLanguageResultExecution timeMemory
132855MinnakhmetovLottery (CEOI18_lot)C++14
100 / 100
995 ms8568 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define all(aaa) aaa.begin(), aaa.end() const int N = 10005, Q = 105; int a[N], b[N], ct[N], ans[N][Q], w[Q], col[N]; vector<int> vs; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); int n, l; cin >> n >> l; for (int i = 0; i < n; i++) { cin >> a[i]; } int q; cin >> q; for (int i = 0; i < q; i++) { cin >> w[i]; vs.push_back(w[i]); } vs.push_back(-1); sort(all(vs)); vs.erase(unique(all(vs)), vs.end()); fill(col, col + N, -1); for (int i = vs.size() - 1; i > 0; i--) { for (int j = vs[i - 1] + 1; j <= vs[i]; j++) { col[j] = i; } } for (int i = 1; i <= n - l; i++) { fill(b, b + n, 0); for (int j = 0; j < n - i; j++) { if (a[j] != a[j + i]) { int x = min(j, l - 1); b[j - x]++; b[j + 1]--; } } for (int j = 1; j <= n - l - i; j++) { b[j] += b[j - 1]; } for (int j = 0; j <= n - l - i; j++) { if (col[b[j]] != -1) { ans[j][col[b[j]]]++; ans[j + i][col[b[j]]]++; } } } for (int i = 1; i < vs.size(); i++) { for (int j = 0; j <= n - l; j++) { ans[j][i] += ans[j][i - 1]; } } for (int i = 0; i < q; i++) { int k = lower_bound(all(vs), w[i]) - vs.begin(); for (int j = 0; j <= n - l; j++) { cout << ans[j][k] << " "; } cout << "\n"; } return 0; }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:70:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < vs.size(); i++) {
                     ~~^~~~~~~~~~~
#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...