답안 #875061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875061 2023-11-18T15:26:25 Z tvladm2009 Lottery (CEOI18_lot) C++17
25 / 100
40 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e4 + 7;
const int Q = 1e2 + 7;

int n, l;
int a[N];
bool b[N][N];
int dist[N][N];
int sum[N];
int ans[Q][N];

int main() {
    ios::sync_with_stdio(false);
    cin.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 = 1; j <= n; ++j) {
            b[i][j] = (a[i] != a[j]);
        }
    }
    vector<pair<int, int>> queries;
    int q;
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        int k;
        cin >> k;
        queries.push_back({k, i});
    }
    for (int i = 1; i <= n - l + 1; ++i) {
        memset(sum, 0, sizeof(sum));
        if (i == 1) {
            for (int j = 1; j <= n - l + 1; ++j) {
                for (int k = 0; k < l; ++k) {
                    dist[i][j] += b[i + k][j + k];
                }
                sum[dist[i][j]]++;
            }
        } else {
            dist[i][1] = 0;
            for (int j = 0; j < l; ++j) {
                dist[i][1] += b[i + j][1 + j];
            }
            sum[dist[i][1]]++;
            for (int j = 2; j <= n - l + 1; ++j) {
                dist[i][j] = dist[i - 1][j - 1] - b[i - 1][j - 1] + b[i + l - 1][j + l - 1];
                sum[dist[i][j]]++;
            }
        }
        for (int j = 1; j <= l; ++j) {
            sum[j] += sum[j - 1];
        }
        for (auto it : queries) {
            ans[it.second][i] = sum[it.first];
        }
    }
    for (int i = 1; i <= q; ++i) {
        for (int j = 1; j <= n - l + 1; ++j) {
            cout << ans[i][j] - 1 << " ";
        }
        cout << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 3 ms 12764 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 2 ms 10712 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 3 ms 16848 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 22876 KB Output is correct
11 Correct 3 ms 22876 KB Output is correct
12 Correct 4 ms 22872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 3 ms 12764 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 2 ms 10712 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 3 ms 16848 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 22876 KB Output is correct
11 Correct 3 ms 22876 KB Output is correct
12 Correct 4 ms 22872 KB Output is correct
13 Runtime error 21 ms 65536 KB Execution killed with signal 9
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 3 ms 12764 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 2 ms 10712 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 3 ms 16848 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 22876 KB Output is correct
11 Correct 3 ms 22876 KB Output is correct
12 Correct 4 ms 22872 KB Output is correct
13 Runtime error 21 ms 65536 KB Execution killed with signal 9
14 Halted 0 ms 0 KB -