Submission #168951

#TimeUsernameProblemLanguageResultExecution timeMemory
168951kostia244Lottery (CEOI18_lot)C++17
25 / 100
149 ms65540 KiB
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
// using vi vector<int>;
const int maxn = 10222;
int n, l, q, x;
int a[maxn], mat[maxn][maxn], cnt[maxn][maxn];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> l;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++)
    for(int j = i+1; j <= n; j++) {
    	if(a[i]==a[j]) continue;
        int diff = j-i;
        int L = max(j-l+1, 1+diff);
        int R = min(j, n-l+1);
        // cout << i << " " << j << " : " << L << " " << R << "\n";
      if(L<=R){
        ++mat[diff][L];
        --mat[diff][R+1];}
    }
    for(int i = 1; i <= n; i++) {
        ll cur = 0;
        for(int j = i+1; j <= n-l+1; j++) {
            cur += mat[i][j];
            // cout << j << " " << j-i << " " << cur << "\n";
            ++cnt[j][cur];
            ++cnt[j-i][cur];
        }
    }
    for(int i = 1; i <= n-l+1; i++) {
        for(int j = 1; j <= n; j++) {
            cnt[i][j] += cnt[i][j-1];
        }
    }
    cin >> q;
    while(q--) {
        cin >> x;
        for(int i = 1; i <= n-l+1; i++) cout << cnt[i][x] << " ";cout << "\n";
    }
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:44:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(int i = 1; i <= n-l+1; i++) cout << cnt[i][x] << " ";cout << "\n";
         ^~~
lot.cpp:44:66: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         for(int i = 1; i <= n-l+1; i++) cout << cnt[i][x] << " ";cout << "\n";
                                                                  ^~~~
#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...