답안 #807043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807043 2023-08-04T12:47:11 Z Valaki2 Lottery (CEOI18_lot) C++14
35 / 100
346 ms 4372 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

const int maxn = 10000; //!!!!!
const int maxq = 100;

int n, l, q;
int v[1 + maxn];
int conv[1 + maxn];
int dp[1 + maxn];
int ans[1 + maxn][1 + maxq];
int qry[1 + maxq];

void solve() {
    cin >> n >> l;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    cin >> q;
    vector<pii> sorted;
    for(int i = 1; i <= q; i++) {
        cin >> qry[i];
        conv[qry[i]] = i;
        sorted.pb(mp(qry[i], i));
    }
    sort(sorted.begin(), sorted.end());
    for(int i = n - 1; i >= 0; i--) {
        if(conv[i] == 0) {
            conv[i] = conv[i + 1];
        }
    }
    for(int offset = 1; offset <= n - l; offset++) {
        for(int i = 1; i <= offset; i++) {
            dp[i] = 0;
        }
        for(int i = 1 + offset; i <= n; i++) {
            dp[i] = dp[i - 1];
            if(v[i] != v[i - offset]) {
                dp[i]++;
            }
            if(i - l + 1 - offset >= 1) {
                #define a (i - l + 1)
                #define b (i - l + 1 - offset)
                #define dist (dp[i] - dp[i - l])
                ans[a][conv[dist]]++;
                ans[b][conv[dist]]++;
            }
        }
    }
    for(int i = 1; i <= n - l + 1; i++) {
        for(int j = 1; j < q; j++) {
            ans[i][sorted[j].se] += ans[i][sorted[j - 1].se];
        }
    }
    for(int i = 1; i <= q; i++) {
        for(int j = 1; j <= n - l + 1; j++) {
            cout << ans[j][i] << " ";
        }
        cout << "\n";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 346 ms 4368 KB Output is correct
2 Correct 339 ms 4368 KB Output is correct
3 Correct 248 ms 4372 KB Output is correct
4 Correct 222 ms 4308 KB Output is correct
5 Correct 108 ms 2416 KB Output is correct
6 Correct 198 ms 4100 KB Output is correct
7 Correct 99 ms 2404 KB Output is correct
8 Correct 137 ms 3192 KB Output is correct
9 Correct 212 ms 4180 KB Output is correct
10 Correct 204 ms 4308 KB Output is correct
11 Correct 13 ms 1108 KB Output is correct
12 Correct 144 ms 3184 KB Output is correct
13 Correct 149 ms 2772 KB Output is correct
14 Correct 129 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 346 ms 4368 KB Output is correct
2 Correct 339 ms 4368 KB Output is correct
3 Correct 248 ms 4372 KB Output is correct
4 Correct 222 ms 4308 KB Output is correct
5 Correct 108 ms 2416 KB Output is correct
6 Correct 198 ms 4100 KB Output is correct
7 Correct 99 ms 2404 KB Output is correct
8 Correct 137 ms 3192 KB Output is correct
9 Correct 212 ms 4180 KB Output is correct
10 Correct 204 ms 4308 KB Output is correct
11 Correct 13 ms 1108 KB Output is correct
12 Correct 144 ms 3184 KB Output is correct
13 Correct 149 ms 2772 KB Output is correct
14 Correct 129 ms 2772 KB Output is correct
15 Correct 236 ms 4248 KB Output is correct
16 Correct 190 ms 3984 KB Output is correct
17 Correct 216 ms 4372 KB Output is correct
18 Correct 214 ms 4332 KB Output is correct
19 Correct 223 ms 4332 KB Output is correct
20 Correct 208 ms 4340 KB Output is correct
21 Correct 200 ms 4340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -