답안 #1033211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033211 2024-07-24T14:20:28 Z warrenn Lottery (CEOI18_lot) C++14
100 / 100
465 ms 12112 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,leng;
    cin>>n>>leng;
    int a[n+1];
    for(int q=1;q<=n;q++){
        cin>>a[q];
    }
    int q;
    cin>>q;
    pair<int,int>tny[q+1];
    for(int w=1;w<=q;w++){
        cin>>tny[w].first;
        tny[w].second=w;
    }
    sort(tny+1,tny+q+1);

    int pos[leng+1];
    memset(pos,-1,sizeof pos);
    for(int w=1;w<=q;w++){
        if(pos[tny[w].first]==-1){
            pos[tny[w].first]=w;
        }
    }

    for(int w=leng-1;w>=0;w--){
        if(pos[w]==-1){
            pos[w]=pos[w+1];
        }
    }

    int cnt[q+1][n+1];
    memset(cnt,0,sizeof cnt);
    for(int w=1;w<=n;w++){
        int l=1,r=w+1;
        int diff=0;
        if(r+leng-1>n)break;
        for(int j=0;j<leng;j++){
            if(a[l+j]!=a[r+j]){
                diff++;
            }
        }

        cnt[pos[diff]][l]++;
        cnt[pos[diff]][r]++;

        while(r+leng<=n){
            if(a[l+leng]!=a[r+leng]){
                diff++;
            }
            if(a[l]!=a[r]){
                diff--;
            }
            l++,r++;
            cnt[pos[diff]][l]++;
            cnt[pos[diff]][r]++;
        }
    }
    for(int w=2;w<=q;w++){
        for(int e=1;e<=n;e++){
            cnt[w][e]+=cnt[w-1][e];
        }
    }
    int ans[q+1][n+1];
    for(int w=1;w<=q;w++){
        for(int e=1;e<=n;e++){
            ans[tny[w].second][e]=cnt[w][e];
        }
    }
    for(int w=1;w<=q;w++){
        for(int e=1;e<=n-leng+1;e++){
            cout<<ans[w][e]<<" ";
        }
        cout<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 7 ms 344 KB Output is correct
14 Correct 4 ms 604 KB Output is correct
15 Correct 4 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 6 ms 860 KB Output is correct
18 Correct 6 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 596 KB Output is correct
2 Correct 400 ms 600 KB Output is correct
3 Correct 135 ms 600 KB Output is correct
4 Correct 91 ms 604 KB Output is correct
5 Correct 49 ms 680 KB Output is correct
6 Correct 84 ms 600 KB Output is correct
7 Correct 46 ms 600 KB Output is correct
8 Correct 70 ms 604 KB Output is correct
9 Correct 106 ms 672 KB Output is correct
10 Correct 107 ms 672 KB Output is correct
11 Correct 7 ms 344 KB Output is correct
12 Correct 60 ms 652 KB Output is correct
13 Correct 47 ms 680 KB Output is correct
14 Correct 55 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 596 KB Output is correct
2 Correct 400 ms 600 KB Output is correct
3 Correct 135 ms 600 KB Output is correct
4 Correct 91 ms 604 KB Output is correct
5 Correct 49 ms 680 KB Output is correct
6 Correct 84 ms 600 KB Output is correct
7 Correct 46 ms 600 KB Output is correct
8 Correct 70 ms 604 KB Output is correct
9 Correct 106 ms 672 KB Output is correct
10 Correct 107 ms 672 KB Output is correct
11 Correct 7 ms 344 KB Output is correct
12 Correct 60 ms 652 KB Output is correct
13 Correct 47 ms 680 KB Output is correct
14 Correct 55 ms 564 KB Output is correct
15 Correct 151 ms 600 KB Output is correct
16 Correct 83 ms 664 KB Output is correct
17 Correct 117 ms 660 KB Output is correct
18 Correct 98 ms 676 KB Output is correct
19 Correct 96 ms 676 KB Output is correct
20 Correct 90 ms 836 KB Output is correct
21 Correct 87 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 7 ms 344 KB Output is correct
14 Correct 4 ms 604 KB Output is correct
15 Correct 4 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 6 ms 860 KB Output is correct
18 Correct 6 ms 628 KB Output is correct
19 Correct 286 ms 596 KB Output is correct
20 Correct 400 ms 600 KB Output is correct
21 Correct 135 ms 600 KB Output is correct
22 Correct 91 ms 604 KB Output is correct
23 Correct 49 ms 680 KB Output is correct
24 Correct 84 ms 600 KB Output is correct
25 Correct 46 ms 600 KB Output is correct
26 Correct 70 ms 604 KB Output is correct
27 Correct 106 ms 672 KB Output is correct
28 Correct 107 ms 672 KB Output is correct
29 Correct 7 ms 344 KB Output is correct
30 Correct 60 ms 652 KB Output is correct
31 Correct 47 ms 680 KB Output is correct
32 Correct 55 ms 564 KB Output is correct
33 Correct 151 ms 600 KB Output is correct
34 Correct 83 ms 664 KB Output is correct
35 Correct 117 ms 660 KB Output is correct
36 Correct 98 ms 676 KB Output is correct
37 Correct 96 ms 676 KB Output is correct
38 Correct 90 ms 836 KB Output is correct
39 Correct 87 ms 600 KB Output is correct
40 Correct 465 ms 2836 KB Output is correct
41 Correct 9 ms 2136 KB Output is correct
42 Correct 122 ms 2900 KB Output is correct
43 Correct 116 ms 2388 KB Output is correct
44 Correct 107 ms 2640 KB Output is correct
45 Correct 456 ms 12092 KB Output is correct
46 Correct 21 ms 8792 KB Output is correct
47 Correct 161 ms 12112 KB Output is correct
48 Correct 135 ms 10444 KB Output is correct
49 Correct 132 ms 11212 KB Output is correct