Submission #1086173

# Submission time Handle Problem Language Result Execution time Memory
1086173 2024-09-09T16:40:05 Z dwuy Lottery (CEOI18_lot) C++14
100 / 100
264 ms 8392 KB
/**         - dwuy -

      />    フ
      |  _  _|
      /`ミ _x ノ
     /      |
    /   ヽ   ?
 / ̄|   | | |
 | ( ̄ヽ__ヽ_)_)
 \二つ

**/
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) (int)((s).size())
#define MASK(k)(1LL<<(k))
#define TASK "test"

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 10003;

int n, ln, q;
int a[MX];  
int qr[MX];
int id[MX];
int ans[MX][103];
vector<int> rv;

void nhap(){
    cin >> n >> ln;
    for(int i=1; i<=n; i++) cin >> a[i];
    cin >> q;
    for(int i=1; i<=q; i++){
        cin >> qr[i];
        rv.push_back(qr[i]);
    }
    sort(rv.begin(), rv.end());
    rv.erase(unique(rv.begin(), rv.end()), rv.end());
}

void solve(){
    id[n+1] = 101;
    for(int i=0; i<len(rv); i++) id[rv[i]] = i + 1;
    for(int i=n; i>=0; i--) id[i] = id[i]? id[i] : id[i+1];
    for(int i=ln + 1; i<=n; i++){
        int cur = 0;
        for(int j=1; j<=ln; j++) cur += a[j] != a[i - ln + j];
        ans[ln][id[cur]]++;
        ans[i][id[cur]]++;
        for(int j=i+1; j<=n; j++){
            cur += a[j] != a[ln + j - i];
            cur -= a[j - ln] != a[j - i];
            ans[ln + j - i][id[cur]]++;
            ans[j][id[cur]]++;
        }
    }
    for(int i=1; i<103; i++){
        for(int j=1; j<=n; j++) ans[j][i] += ans[j][i-1];
    }
    for(int j=1; j<=q; j++){
        for(int i=ln; i<=n; i++) cout << ans[i][id[qr[j]]] << ' ';
        cout << endl;
    }
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    solve();


    return 0;
}

/*

9 3
1 2 3 1 2 3 1 2 3
1
1

*/

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 7 ms 2720 KB Output is correct
14 Correct 5 ms 1248 KB Output is correct
15 Correct 5 ms 1116 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 7 ms 1372 KB Output is correct
18 Correct 8 ms 1196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 4552 KB Output is correct
2 Correct 174 ms 4444 KB Output is correct
3 Correct 184 ms 4580 KB Output is correct
4 Correct 172 ms 4444 KB Output is correct
5 Correct 63 ms 4432 KB Output is correct
6 Correct 177 ms 4436 KB Output is correct
7 Correct 82 ms 4452 KB Output is correct
8 Correct 108 ms 4468 KB Output is correct
9 Correct 173 ms 4440 KB Output is correct
10 Correct 176 ms 4440 KB Output is correct
11 Correct 8 ms 2652 KB Output is correct
12 Correct 95 ms 4176 KB Output is correct
13 Correct 78 ms 4436 KB Output is correct
14 Correct 78 ms 4540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 4552 KB Output is correct
2 Correct 174 ms 4444 KB Output is correct
3 Correct 184 ms 4580 KB Output is correct
4 Correct 172 ms 4444 KB Output is correct
5 Correct 63 ms 4432 KB Output is correct
6 Correct 177 ms 4436 KB Output is correct
7 Correct 82 ms 4452 KB Output is correct
8 Correct 108 ms 4468 KB Output is correct
9 Correct 173 ms 4440 KB Output is correct
10 Correct 176 ms 4440 KB Output is correct
11 Correct 8 ms 2652 KB Output is correct
12 Correct 95 ms 4176 KB Output is correct
13 Correct 78 ms 4436 KB Output is correct
14 Correct 78 ms 4540 KB Output is correct
15 Correct 187 ms 4464 KB Output is correct
16 Correct 165 ms 4484 KB Output is correct
17 Correct 180 ms 4648 KB Output is correct
18 Correct 185 ms 4612 KB Output is correct
19 Correct 190 ms 4604 KB Output is correct
20 Correct 191 ms 4608 KB Output is correct
21 Correct 178 ms 4616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 7 ms 2720 KB Output is correct
14 Correct 5 ms 1248 KB Output is correct
15 Correct 5 ms 1116 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 7 ms 1372 KB Output is correct
18 Correct 8 ms 1196 KB Output is correct
19 Correct 194 ms 4552 KB Output is correct
20 Correct 174 ms 4444 KB Output is correct
21 Correct 184 ms 4580 KB Output is correct
22 Correct 172 ms 4444 KB Output is correct
23 Correct 63 ms 4432 KB Output is correct
24 Correct 177 ms 4436 KB Output is correct
25 Correct 82 ms 4452 KB Output is correct
26 Correct 108 ms 4468 KB Output is correct
27 Correct 173 ms 4440 KB Output is correct
28 Correct 176 ms 4440 KB Output is correct
29 Correct 8 ms 2652 KB Output is correct
30 Correct 95 ms 4176 KB Output is correct
31 Correct 78 ms 4436 KB Output is correct
32 Correct 78 ms 4540 KB Output is correct
33 Correct 187 ms 4464 KB Output is correct
34 Correct 165 ms 4484 KB Output is correct
35 Correct 180 ms 4648 KB Output is correct
36 Correct 185 ms 4612 KB Output is correct
37 Correct 190 ms 4604 KB Output is correct
38 Correct 191 ms 4608 KB Output is correct
39 Correct 178 ms 4616 KB Output is correct
40 Correct 205 ms 5200 KB Output is correct
41 Correct 13 ms 4696 KB Output is correct
42 Correct 200 ms 5204 KB Output is correct
43 Correct 175 ms 5000 KB Output is correct
44 Correct 191 ms 4948 KB Output is correct
45 Correct 264 ms 8392 KB Output is correct
46 Correct 21 ms 4952 KB Output is correct
47 Correct 222 ms 8304 KB Output is correct
48 Correct 208 ms 6520 KB Output is correct
49 Correct 237 ms 7256 KB Output is correct